From bd2a350c422216e7905e91027e3c56a91c22d3cc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 3 Aug 2014 12:47:51 +0000 Subject: [PATCH] Fix window position calculation in wxMSW when using RTL. Just use the native ::MapWindowPoints() to do the coordinate transformation instead of doing it ourselves: we did it wrongly by inheriting the layout direction from wxTheApp instead of from the parent window, so fix this in the best possible way by not doing it at all and just relying on Windows to do it for us. In particular, this corrects the display of wxStatusBar in RTL frames. Closes #15031. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76992 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/window.cpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 5352d49b32..3831de0eb4 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1856,31 +1856,18 @@ void wxWindowMSW::DoGetPosition(int *x, int *y) const { RECT rect = wxGetWindowRect(GetHwnd()); - POINT point; - point.x = rect.left; - point.y = rect.top; - // we do the adjustments with respect to the parent only for the "real" // children, not for the dialogs/frames if ( !IsTopLevel() ) { - if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft ) - { - // In RTL mode, we want the logical left x-coordinate, - // which would be the physical right x-coordinate. - point.x = rect.right; - } - - // Since we now have the absolute screen coords, if there's a - // parent we must subtract its top left corner - if ( parent ) - { - ::ScreenToClient(GetHwndOf(parent), &point); - } + // In RTL mode, we want the logical left x-coordinate, + // which would be the physical right x-coordinate. + ::MapWindowPoints(NULL, parent ? GetHwndOf(parent) : HWND_DESKTOP, + (LPPOINT)&rect, 2); } - pos.x = point.x; - pos.y = point.y; + pos.x = rect.left; + pos.y = rect.top; } // we also must adjust by the client area offset: a control which is just