]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix client to screen translation in wxWindowMSW::PopupMenu().
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 17 May 2011 13:35:04 +0000 (13:35 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 17 May 2011 13:35:04 +0000 (13:35 +0000)
Use wxWidgets ClientToScreen() function for computing the screen coordinates
of the popup menu instead of Windows ::ClientToScreen() as the latter doesn't
know about the toolbar which may be present in wxFrame and excluded from the
client area.

Closes #13223.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67758 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/window.cpp

index 246f47ba11d87546f03aefb9747703c564ea22ae..31c9f5e62ec26ffce135204bdd396e530ec5fb45 100644 (file)
@@ -2213,18 +2213,16 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y)
 {
     menu->UpdateUI();
 
+    wxPoint pt;
     if ( x == wxDefaultCoord && y == wxDefaultCoord )
     {
-        wxPoint mouse = ScreenToClient(wxGetMousePosition());
-        x = mouse.x; y = mouse.y;
+        pt = wxGetMousePosition();
+    }
+    else
+    {
+        pt = ClientToScreen(wxPoint(x, y));
     }
 
-    HWND hWnd = GetHwnd();
-    HMENU hMenu = GetHmenuOf(menu);
-    POINT point;
-    point.x = x;
-    point.y = y;
-    ::ClientToScreen(hWnd, &point);
 #if defined(__WXWINCE__)
     static const UINT flags = 0;
 #else // !__WXWINCE__
@@ -2242,7 +2240,7 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y)
     }
 #endif // __WXWINCE__/!__WXWINCE__
 
-    ::TrackPopupMenu(hMenu, flags, point.x, point.y, 0, hWnd, NULL);
+    ::TrackPopupMenu(GetHmenuOf(menu), flags, pt.x, pt.y, 0, GetHwnd(), NULL);
 
     // we need to do it right now as otherwise the events are never going to be
     // sent to wxCurrentPopupMenu from HandleCommand()