WM_UNINITMENUPOPUP is "only" available since Windows 98/2000 so restore the
old code using WM_EXITMENULOOP as fall back, just to avoid any regressions for
people who might still be using these systems.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70156
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// wxMDIChildFrame
bool MSWDoTranslateMessage(wxFrame *frame, WXMSG *msg);
// wxMDIChildFrame
bool MSWDoTranslateMessage(wxFrame *frame, WXMSG *msg);
+#if wxUSE_MENUS
+ // handle WM_EXITMENULOOP message for Win95 only
+ bool HandleExitMenuLoop(WXWORD isPopup);
+
// handle WM_(UN)INITMENUPOPUP message to generate wxEVT_MENU_OPEN/CLOSE
bool HandleMenuPopup(wxEventType evtType, WXHMENU hMenu);
// handle WM_(UN)INITMENUPOPUP message to generate wxEVT_MENU_OPEN/CLOSE
bool HandleMenuPopup(wxEventType evtType, WXHMENU hMenu);
+ // Command part of HandleMenuPopup() and HandleExitMenuLoop().
+ bool DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu, bool popup);
+#endif // wxUSE_MENUS
+
+
virtual bool IsMDIChild() const { return false; }
// get default (wxWidgets) icon for the frame
virtual bool IsMDIChild() const { return false; }
// get default (wxWidgets) icon for the frame
-bool wxFrame::HandleMenuPopup(wxEventType evtType, WXHMENU hMenu)
+bool
+wxFrame::DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu, bool popup)
+{
+ wxMenuEvent event(evtType, popup ? wxID_ANY : 0, menu);
+ event.SetEventObject(this);
+
+ return HandleWindowEvent(event);
+}
+
+bool wxFrame::HandleExitMenuLoop(WXWORD isPopup)
- // we don't have the menu id here, so we use the id to specify if the event
- // was from a popup menu or a normal one
+ return DoSendMenuOpenCloseEvent(wxEVT_MENU_CLOSE,
+ isPopup ? wxCurrentPopupMenu : NULL,
+ isPopup != 0);
+}
+bool wxFrame::HandleMenuPopup(wxEventType evtType, WXHMENU hMenu)
+{
+ bool isPopup = false;
+ if ( wxCurrentPopupMenu && wxCurrentPopupMenu->GetHMenu() == hMenu )
- menu = GetMenuBar()->MSWGetMenu(hMenu);
+ menu = wxCurrentPopupMenu;
+ isPopup = true;
- else if ( wxCurrentPopupMenu && wxCurrentPopupMenu->GetHMenu() == hMenu )
+ else if ( GetMenuBar() )
- menu = wxCurrentPopupMenu;
- menuid = wxID_ANY;
+ menu = GetMenuBar()->MSWGetMenu(hMenu);
- wxMenuEvent event(evtType, menuid, menu);
- event.SetEventObject(this);
- return HandleWindowEvent(event);
+ return DoSendMenuOpenCloseEvent(evtType, menu, isPopup);
+ case WM_EXITMENULOOP:
+ // Under Windows 98 and 2000 and later we're going to get
+ // WM_UNINITMENUPOPUP which will be used to generate this event
+ // with more information (notably the menu that was closed) so we
+ // only need this one under old Windows systems where the newer
+ // event is never sent.
+ if ( wxGetWinVersion() < wxWinVersion_98 )
+ processed = HandleExitMenuLoop(wParam);
+ break;
+
case WM_UNINITMENUPOPUP:
processed = HandleMenuPopup(wxEVT_MENU_CLOSE, (WXHMENU)wParam);
break;
case WM_UNINITMENUPOPUP:
processed = HandleMenuPopup(wxEVT_MENU_CLOSE, (WXHMENU)wParam);
break;