Fix failing Win32 calls with checkable menu item.

Since r76202 InsertMenuItem is used when adding checkable menu items even
without a bitmap. The call fails because hbmpChecked and hbmpUnchecked are
set to HBMMENU_CALLBACK on pre-Vista, making the menu owner drawn
unnecessarily.

Fix by adding GetHBitmapForMenuCheckable which is used when assigning
values to hbmpChecked and hbmpUnchecked. GetHBitmapForMenu remains
unchanged (for possible porting reasons) and is used for hBmpItem only.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76757 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Dimitri Schoolwerth
2014-06-23 20:05:30 +00:00
parent 1697a45b1f
commit 6b12639c49
4 changed files with 91 additions and 40 deletions

View File

@@ -25,7 +25,9 @@
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/bitmap.h"
#include "wx/frame.h"
#include "wx/image.h"
#include "wx/menu.h"
#include "wx/msgdlg.h"
#include "wx/log.h"
@@ -607,6 +609,33 @@ MyFrame::MyFrame()
testMenu->Append(Menu_Test_Normal, wxT("&Normal item"));
testMenu->AppendSeparator();
testMenu->AppendCheckItem(Menu_Test_Check, wxT("&Check item"));
#ifdef __WXMSW__
#if wxUSE_IMAGE
wxBitmap bmpUnchecked(8, 8);
wxImage imageChecked(8, 8);
imageChecked.Clear(0xff);
wxBitmap bmpChecked(imageChecked);
wxMenuItem *checkedBitmapItem = new wxMenuItem(testMenu, wxID_ANY,
"Check item with bitmaps", "", wxITEM_CHECK);
checkedBitmapItem->SetBitmaps(bmpChecked, bmpUnchecked);
testMenu->Append(checkedBitmapItem);
checkedBitmapItem = new wxMenuItem(testMenu, wxID_ANY,
"Check item with bitmaps set afterwards", "", wxITEM_CHECK);
testMenu->Append(checkedBitmapItem);
checkedBitmapItem->SetBitmaps(bmpChecked, bmpUnchecked);
checkedBitmapItem = new wxMenuItem(testMenu, wxID_ANY,
"Check item with bitmaps set afterwards (initially checked)", "", wxITEM_CHECK);
testMenu->Append(checkedBitmapItem);
checkedBitmapItem->Check();
checkedBitmapItem->SetBitmaps(bmpChecked, bmpUnchecked);
#endif
#endif
testMenu->AppendSeparator();
testMenu->AppendRadioItem(Menu_Test_Radio1, wxT("Radio item &1"));
testMenu->AppendRadioItem(Menu_Test_Radio2, wxT("Radio item &2"));