From 4c152f466f955556b8b13f450c20e169022fae16 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 2 Mar 2014 13:34:14 +0000 Subject: [PATCH] Fix setting the label for already existing menu items with bitmaps in wxMSW. Do update the label at Windows level if we don't use MF_OWNERDRAW style, checking for IsOwnerDrawn() is wrong because the flag it tests may be set even if the item is not really owner drawn from Windows point of view. This is a mess and setting the bitmap for the existing items is still broken, but at least setting the label works now. See #9388. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76044 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/menuitem.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index f37017e1b1..3c09d878fa 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -673,7 +673,11 @@ void wxMenuItem::SetItemLabel(const wxString& txt) const UINT id = GetMSWId(); HMENU hMenu = GetHMenuOf(m_parentMenu); - if ( !hMenu || ::GetMenuState(hMenu, id, MF_BYCOMMAND) == (UINT)-1 ) + if ( !hMenu ) + return; + + const UINT state = ::GetMenuState(hMenu, id, MF_BYCOMMAND); + if ( state == (UINT)-1 ) return; // update the text of the native menu item @@ -708,7 +712,11 @@ void wxMenuItem::SetItemLabel(const wxString& txt) // items however as otherwise their size wouldn't be recalculated as // WM_MEASUREITEM wouldn't be sent and this could result in display // problems if the length of the menu item changed significantly. - if ( !IsOwnerDrawn() ) + // + // Also notice that we shouldn't use our IsOwnerDrawn() because it can be + // true because it was set by e.g. SetBitmap(), even if the item wasn't + // made owner drawn at Windows level. + if ( !(state & MF_OWNERDRAW) ) #endif // wxUSE_OWNER_DRAWN { if ( isLaterThanWin95 )