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
This commit is contained in:
Vadim Zeitlin
2010-01-23 13:21:20 +00:00
parent 98fbab9e7b
commit 4e7c767fed

View File

@@ -401,6 +401,9 @@ HBITMAP GetHBitmapForMenu(wxMenuItem *pItem, bool checked = true)
return GetHbitmapOf(pItem->GetBitmap(checked)); return GetHbitmapOf(pItem->GetBitmap(checked));
} }
//else: bitmap is not set
return NULL;
} }
#endif // wxUSE_IMAGE #endif // wxUSE_IMAGE
@@ -518,18 +521,19 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
WinStruct<MENUITEMINFO> mii; WinStruct<MENUITEMINFO> mii;
mii.fMask = MIIM_STRING | MIIM_DATA; mii.fMask = MIIM_STRING | MIIM_DATA;
if ( pItem->GetBitmap().IsOk() ) // don't set hbmpItem for the checkable items as it would
{ // be used for both checked and unchecked state
mii.fMask |= MIIM_BITMAP;
mii.hbmpItem = GetHBitmapForMenu(pItem);
}
if ( pItem->IsCheckable() ) if ( pItem->IsCheckable() )
{ {
mii.fMask |= MIIM_CHECKMARKS; mii.fMask |= MIIM_CHECKMARKS;
mii.hbmpChecked = GetHBitmapForMenu(pItem, true); mii.hbmpChecked = GetHBitmapForMenu(pItem, true);
mii.hbmpUnchecked = GetHBitmapForMenu(pItem, false); mii.hbmpUnchecked = GetHBitmapForMenu(pItem, false);
} }
else if ( pItem->GetBitmap().IsOk() )
{
mii.fMask |= MIIM_BITMAP;
mii.hbmpItem = GetHBitmapForMenu(pItem);
}
mii.cch = itemText.length(); mii.cch = itemText.length();
mii.dwTypeData = const_cast<wxChar *>(itemText.wx_str()); mii.dwTypeData = const_cast<wxChar *>(itemText.wx_str());