[Solved] wxMenuItem HOWTO add a wxBitmap?
BlitzMax Forums/Brucey's Modules/[Solved] wxMenuItem HOWTO add a wxBitmap?
| ||
What do I wrong? I can't bind a bitmap to a wxMenuItem: Local mtm:wxMenuItem = MOBii_Menu[q].Menu.FindChildItem(_menuid, _pos) If mtm.wxObjectPtr Then mtm.setBitmap(GetSubPic(_bitmap, _pic)) ' mtm.SetBitmaps(GetSubPic(_bitmap, _pic)) ' I test this too to be sure! End IfI can set picture to all other wxobject I tested but not to wxMenuItem Still probably me doing something wrong, I maybe just need to update somehow I been trying: MBar = MFrame.GetMenuBar() MFrame.SetMenuBar(MBar) MBar.RefreshMenuBar()I make testcode: Local _pos:Int Local mtm:wxMenuItem = MOBii_Menu[q].Menu.FindChildItem(8001, _pos) Local b:wxBitmap = mtm.getBitmap() echo "Bitmap width: " + b.GetWidth() echo "Bitmap height: " + b.GetHeight() echo "Label: " + mtm.GetItemLabel()output: Bitmap width: 16 Bitmap height: 16 Label: &New Ctrl-N So I can see the menu Label and that the Bitmap has 16x16pixels width, height but I can't make the bitmap to appear on the wxMenuItem |
| ||
Hi, this is my menu creation code for reference: I added one line just to test that graphics work. My bitmap is 24 x 24. -Henri |
| ||
Happy Xmas and thank thee Henri this is your code that I alter that works for me: Local mtm:wxMenuItem = New wxMenuItem.Create(MOBii_Menu[q].Menu, id, Txt, Inf, wxITEM_NORMAL) If _bitmap > 0 Then mtm.setBitmap(GetSubPic(_bitmap, _pic1)) MOBii_Menu[q].Menu.AppendItem(mtm) MBar.Insert(_pos, MOBii_Menu[q].Menu, MOBii_Menu[q].title)My old code still don't work MOBii_Menu[q].Menu.append(id, Txt, Inf, wxITEM_NORMAL) MBar.Insert(_pos, MOBii_Menu[q].Menu, MOBii_Menu[q].title) Local mtm:wxMenuItem = MOBii_Menu[q].Menu.FindChildItem(_menuid, _pos) If mtm.wxObjectPtr Then mtm.setBitmap(GetSubPic(_bitmap, _pic))Question: can I set image after I MBar.Insert(_pos, MOBii_Menu[q].Menu, MOBii_Menu[q].title)? Is it possible that I after MBar.Insert can change menu icon? I still can cheat and delete the whole menu and recreate the menu with the new icon! |
| ||
Hi, I seems that you can simply by calling SetBitmap() - method again with a different bitmap. -Henri |
| ||
That's what I was thinking too I try upgrade wx.mod see if I can make it work too still happy I can just MOBii_Menu[q].Menu.AppendItem(mtm) |