From: Vadim Zeitlin Date: Sat, 23 Jan 2010 13:21:20 +0000 (+0000) Subject: Set up menu bitmaps correctly for checkable items. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4e7c767fed7847b135aef7617eb6ed2cca1c9e1e Set up menu bitmaps correctly for checkable items. We must not set MENUITEMINFO::hbmpItem for the checkable items as it would then be used for both checked and unchecked state. Closes #11244. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63221 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index d1f777f816..07541b8554 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -401,6 +401,9 @@ HBITMAP GetHBitmapForMenu(wxMenuItem *pItem, bool checked = true) return GetHbitmapOf(pItem->GetBitmap(checked)); } + //else: bitmap is not set + + return NULL; } #endif // wxUSE_IMAGE @@ -518,18 +521,19 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) WinStruct mii; mii.fMask = MIIM_STRING | MIIM_DATA; - if ( pItem->GetBitmap().IsOk() ) - { - mii.fMask |= MIIM_BITMAP; - mii.hbmpItem = GetHBitmapForMenu(pItem); - } - + // don't set hbmpItem for the checkable items as it would + // be used for both checked and unchecked state if ( pItem->IsCheckable() ) { mii.fMask |= MIIM_CHECKMARKS; mii.hbmpChecked = GetHBitmapForMenu(pItem, true); mii.hbmpUnchecked = GetHBitmapForMenu(pItem, false); } + else if ( pItem->GetBitmap().IsOk() ) + { + mii.fMask |= MIIM_BITMAP; + mii.hbmpItem = GetHBitmapForMenu(pItem); + } mii.cch = itemText.length(); mii.dwTypeData = const_cast(itemText.wx_str());