refactor WM_COMMAND messages handling in MDI frames to avoid duplicating code unnecessarily and generally streamline it; added possibility to use custom menu commands in the "Window" menu and specifying accelerators for them now works too (show this in the sample); finally added standard ids for the MDI window menu commands

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58462 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-01-27 16:47:41 +00:00
parent 67fdb6f9af
commit 1483e5db8d
9 changed files with 216 additions and 201 deletions

View File

@@ -890,8 +890,9 @@ bool wxFrame::HandleSize(int WXUNUSED(x), int WXUNUSED(y), WXUINT id)
return false;
}
bool wxFrame::HandleCommand(WXWORD id_, WXWORD cmd, WXHWND control)
bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
{
#if wxUSE_MENUS
// we only need to handle the menu and accelerator commands from the items
// of our menu bar, base wxWindow class already handles the rest
if ( !control && (cmd == 0 /* menu */ || cmd == 1 /* accel */) )
@@ -900,25 +901,24 @@ bool wxFrame::HandleCommand(WXWORD id_, WXWORD cmd, WXHWND control)
if ( !wxCurrentPopupMenu )
#endif // wxUSE_MENUS_NATIVE
{
wxMenuBar * const mbar = GetMenuBar();
if ( mbar )
{
// sign extend to int from short before comparing with the
// other int ids
const int id = (signed short)id_;
wxMenuItem * const mitem = mbar->FindItem(id);
if ( mitem )
return ProcessCommand(mitem);
}
wxMenuItem * const mitem = MSWFindMenuBarItem(id);
if ( mitem )
return ProcessCommand(mitem);
}
}
#endif // wxUSE_MENUS
return wxFrameBase::HandleCommand(id_, cmd, control);;
return wxFrameBase::HandleCommand(id, cmd, control);;
}
#if wxUSE_MENUS
wxMenuItem *wxFrame::MSWFindMenuBarItem(WXWORD id)
{
wxMenuBar * const mbar = GetMenuBar();
return mbar ? mbar->FindItem((signed short)id) : NULL;
}
bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
{
int item;