widgets menus

带有图片的toolbar

wxImage::AddHandler(new wxPNGHandler);
// 增加图片 exit.png
wxBitmap exit(wxT("exit.png"), wxBITMAP_TYPE_PNG);

// wxToolBar *toolbar = new wxToolBar(this, wxID_ANY);
wxToolBar *toolbar = CreateToolBar();

toolbar->AddTool(wxID_EXIT, wxT("Exit application"), exit);

// 实现
toolbar->Realize();

Connect(wxID_EXIT, wxEVT_COMMAND_TOOL_CLICKED, 
    wxCommandEventHandler(Toolbar::OnQuit));

menubar增加menu

  menubar = new wxMenuBar;
  file = new wxMenu;
  file->Append(wxID_EXIT, wxT("&Quit"));
  // 增加分割线
  file->AppendSeparator();
  // file->AppendSubMenu(wxMenu, wxT("&Import"));
  // file->Append(wxMenuItem);
  menubar->Append(file, wxT("&File"));
  SetMenuBar(menubar);

  Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
      wxCommandEventHandler(SimpleMenu::OnQuit));
发布了2 篇原创文章 · 获赞 0 · 访问量 28

猜你喜欢

转载自blog.csdn.net/weixin_42122840/article/details/104031457