]> git.saurik.com Git - wxWidgets.git/commitdiff
menu title is drawn in bold font and the commands from it are ignored
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 6 Feb 1999 23:38:19 +0000 (23:38 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 6 Feb 1999 23:38:19 +0000 (23:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1626 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/menu.cpp

index 670372224f4b50ef241b7786d0fb989ec9bce41c..a24f0f419de9050c2fc17c1070ea7824c149404d 100644 (file)
@@ -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
 }
 
 const wxString wxMenu::GetTitle() const
@@ -413,12 +425,19 @@ wxString wxMenu::GetLabel(int id) const
 
 bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id)
 {
 
 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.
 }
 
 // Finds the item id matching the given string, -1 if not found.