From a3f4e9e81afa4f435b137ebbfb5b07e98a698271 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 6 Feb 1999 23:38:19 +0000 Subject: [PATCH] menu title is drawn in bold font and the commands from it are ignored git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1626 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/menu.cpp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 670372224f..a24f0f419d 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -341,7 +341,19 @@ void wxMenu::SetTitle(const wxString& label) } } - // TODO use SetMenuItemInfo(MFS_DEFAULT) to put it in bold face + // put the title string in bold face + if ( !m_title.IsEmpty() ) + { + MENUITEMINFO mii; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STATE; + mii.fState = MFS_DEFAULT; + + if ( !SetMenuItemInfo(hMenu, (unsigned)idMenuTitle, FALSE, &mii) ) + { + wxLogLastError("SetMenuItemInfo"); + } + } } const wxString wxMenu::GetTitle() const @@ -413,12 +425,19 @@ wxString wxMenu::GetLabel(int id) const bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id) { - wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED); - event.SetEventObject( this ); - event.SetId( id ); - event.SetInt( id ); - ProcessCommand(event); - return TRUE; + // ignore commands from the menu title + + // NB: VC++ generates wrong assembler for `if ( id != idMenuTitle )'!! + if ( id != (WXWORD)idMenuTitle ) + { + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED); + event.SetEventObject( this ); + event.SetId( id ); + event.SetInt( id ); + ProcessCommand(event); + } + + return TRUE; } // Finds the item id matching the given string, -1 if not found.