diff --git a/include/wx/msw/msgdlg.h b/include/wx/msw/msgdlg.h index 784d339b61..30573d8eac 100644 --- a/include/wx/msw/msgdlg.h +++ b/include/wx/msw/msgdlg.h @@ -32,6 +32,10 @@ public: // return the font used for the text in the message box static wxFont GetMessageFont(); +protected: + // Override this as task dialogs are always centered on parent. + virtual void DoCentre(int dir); + private: // hook procedure used to adjust the message box beyond what the standard // MessageBox() function can do for us diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index f6057f7361..35332c4d70 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -600,6 +600,19 @@ int wxMessageDialog::ShowModal() return ShowMessageBox(); } +void wxMessageDialog::DoCentre(int dir) +{ +#ifdef wxHAS_MSW_TASKDIALOG + // Task dialog is always centered on its parent window and trying to center + // it manually doesn't work because its HWND is not created yet so don't + // even try as this would only result in (debug) error messages. + if ( HasNativeTaskDialog() ) + return; +#endif // wxHAS_MSW_TASKDIALOG + + return wxMessageDialogBase::DoCentre(dir); +} + // ---------------------------------------------------------------------------- // Helpers of the wxMSWMessageDialog namespace // ----------------------------------------------------------------------------