]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix bug with using incorrect negative ids in wxEVT_MENU_HIGHLIGHT events.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 22 Apr 2010 11:21:25 +0000 (11:21 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 22 Apr 2010 11:21:25 +0000 (11:21 +0000)
wxMSW code implicitly cast ids carried by wxEVT_MENU_HIGHLIGHT events to
unsigned short so that they didn't compare equal to the (signed, negative) ids
of the real menu items. Because of this menu help strings were not shown for
any items with negative ids, i.e. those created using wxID_ANY.

Closes #11977.

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

src/msw/frame.cpp

index b7348f020e6bfeeebfd891fef3ab89a17b47cdb2..b820a08d2159c89b91344b627366a1a8c9ad6d3a 100644 (file)
@@ -896,11 +896,15 @@ bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
 bool
 wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU WXUNUSED(hMenu))
 {
+    // sign extend to int from unsigned short we get from Windows
+    int item = (signed short)nItem;
+
     // WM_MENUSELECT is generated for both normal items and menus, including
     // the top level menus of the menu bar, which can't be represented using
-    // any valid identifier in wxMenuEvent so use -1 for them
-    // the menu highlight events for n
-    const int item = flags & (MF_POPUP | MF_SEPARATOR) ? -1 : nItem;
+    // any valid identifier in wxMenuEvent so use an otherwise unused value for
+    // them
+    if ( flags & (MF_POPUP | MF_SEPARATOR) )
+        item = -1;
 
     wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
     event.SetEventObject(this);