Ticket #11595 (closed defect: fixed)
Bitmap in menu items disappear on Windows
| Reported by: | congelli501 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | wxMSW | Version: | 2.9-svn |
| Keywords: | menu item bitmap icon label | Cc: | malcompl |
| Blocked By: | Patch: | no | |
| Blocking: |
Description
Hello !
On Windows (this problem doesn't exist on wxGTK), when I change the wxMenuItem label, the bitmap associated to the menu item disappear... and it's impossible to add a new one.
Here is an example.
App.hpp :
//------------------------------------------------------------------------------
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
//------------------------------------------------------------------------------
#include "MainFrame.hpp"
//------------------------------------------------------------------------------
#if not defined APP_HPP_AUTO_SAVE
#define APP_HPP_AUTO_SAVE
class App : public wxApp
{
public:
virtual bool OnInit();
private:
MainFrame *m_frame;
};
//------------------------------------------------------------------------------
#endif //APP_HPP_AUTO_SAVE
App.cpp :
//------------------------------------------------------------------------------
#include "App.hpp"
//------------------------------------------------------------------------------
IMPLEMENT_APP(App)
//------------------------------------------------------------------------------
bool App::OnInit()
{
m_frame = new MainFrame(_T("test"), wxDefaultPosition, wxSize(300, 300));
m_frame->Show(true);
return true;
}
//------------------------------------------------------------------------------
MainFrame.hpp :
//------------------------------------------------------------------------------
#if not defined MAIN_FRAME_HPP_AUTO_SAVE
#define MAIN_FRAME_HPP_AUTO_SAVE
//------------------------------------------------------------------------------
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
//------------------------------------------------------------------------------
class MainFrame : public wxFrame
{
public:
MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
void OnQuit(wxCommandEvent& event);
void OnBtUpdate(wxCommandEvent& event);
protected:
wxMenuItem *m_MenuItem;
wxMenuBar *m_MenuBar;
};
#endif //MAIN_FRAME_HPP_AUTO_SAVE
MainFrame.cpp :
//------------------------------------------------------------------------------
#include "MainFrame.hpp"
//------------------------------------------------------------------------------
/* XPM */
static char * ok_xpm[] = {
"16 16 3 1",
" c #000000",
". c #FFFF00",
"+ c #FF0000",
" .......",
" ........",
" ++ .........",
" ++...+++....",
" +...+..+.. ",
" ..+..+..+. ",
" ...+...+.+ ",
" ....++++..+ ",
" .......... + ",
".......... + ",
".....++++++++ ",
"........ ",
"....... ",
"...... ",
"..... .",
".... .."};
//------------------------------------------------------------------------------
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(NULL, -1, title, pos, size, style)
{
// File menu
wxMenu *FileMenu = new wxMenu;
m_MenuItem = new wxMenuItem(FileMenu, wxID_ANY, _T("Test"));
m_MenuItem->SetBitmap(wxBitmap(ok_xpm));
FileMenu->Append(m_MenuItem);
// Menubar
m_MenuBar = new wxMenuBar();
m_MenuBar->Append(FileMenu,_("&File"));
SetMenuBar(m_MenuBar);
// Events
Connect( m_MenuItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnBtUpdate));
}
//------------------------------------------------------------------------------
void MainFrame::OnBtUpdate(wxCommandEvent& event)
{
m_MenuItem->SetItemLabel(_T("Coucou"));
}
//------------------------------------------------------------------------------
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

