Fix positioning of wxMessageBox with iconized parent in wxMSW

It was shown in the top left corner which was unexpected, so avoid using
TDF_POSITION_RELATIVE_TO_WINDOW (whose implementation is arguably buggy)
in this case to show it in the center of the screen instead.

Closes #26262.
This commit is contained in:
Vadim Zeitlin
2026-03-04 20:04:57 +01:00
parent 1aa3cce252
commit 29bdfb3f93

View File

@@ -646,7 +646,6 @@ void wxMSWTaskDialogConfig::MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc)
// fully shown for reasonably-sized words whereas without it using almost
// any file system path in a message box would result in truncation.
tdc.dwFlags = TDF_EXPAND_FOOTER_AREA |
TDF_POSITION_RELATIVE_TO_WINDOW |
TDF_SIZE_TO_CONTENT;
tdc.hInstance = wxGetInstance();
tdc.pszWindowTitle = caption.t_str();
@@ -654,6 +653,13 @@ void wxMSWTaskDialogConfig::MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc)
// use the top level window as parent if none specified
tdc.hwndParent = parent ? GetHwndOf(parent) : nullptr;
// Don't use this flag if our parent window is minimized because this
// results in the task dialog being shown in the top left corner of the
// screen, which is completely unexpected, so prefer the default behaviour
// of centering the dialog on the screen in this case.
if ( parent && !::IsIconic(tdc.hwndParent) )
tdc.dwFlags |= TDF_POSITION_RELATIVE_TO_WINDOW;
if ( wxApp::MSWGetDefaultLayout(parent) == wxLayout_RightToLeft )
tdc.dwFlags |= TDF_RTL_LAYOUT;