From 5d8d4b669a311a8b0c64939e82fc4d5bb6c36796 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 8 Aug 2011 15:15:50 +0000 Subject: [PATCH] Don't manually centre dialogs created with default position in wxMSW. We always centered the dialogs on the main display which was wrong if the parent window was on another one. Instead of fixing it, simply don't centre them at all and let Windows position them, there is no reason to change the default behaviour. Closes #13387. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68606 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/toplevel.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 856e761b39..495b865e52 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -439,25 +439,26 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, } #endif // !__WXWINCE__ +#if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__) // move the dialog to its initial position without forcing repainting int x, y, w, h; (void)MSWGetCreateWindowCoords(pos, size, x, y, w, h); if ( x == (int)CW_USEDEFAULT ) { - // centre it on the screen - what else can we do? - wxSize sizeDpy = wxGetDisplaySize(); - - x = (sizeDpy.x - w) / 2; - y = (sizeDpy.y - h) / 2; + // Let the system position the window, just set its size. + ::SetWindowPos(GetHwnd(), 0, + 0, 0, w, h, + SWP_NOMOVE | SWP_NOZORDER); } - -#if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__) - if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) ) + else // Move the window to the desired location and set its size too. { - wxLogLastError(wxT("MoveWindow")); + if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) ) + { + wxLogLastError(wxT("MoveWindow")); + } } -#endif +#endif // !__WXWINCE__ if ( !title.empty() ) { -- 2.45.2