加载一个menu.xrc文件
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1"> <object class="wxMenuBar" name="m_menubar1"> <label>MyMenuBar</label> <object class="wxMenu" name="m_menu1"> <label>File</label> <object class="wxMenuItem" name="m_menuItem1"> <label>Open</label> <help></help> </object> <object class="wxMenuItem" name="m_menuItem2"> <label>Select</label> <help></help> </object> <object class="wxMenuItem" name="m_menuItem3"> <label>Select ALL</label> <help></help> </object> <object class="wxMenuItem" name="m_menuItem4"> <label>Exit\tCtrl+Q</label> <help></help> </object> </object>
</object> </resource>
然后在初始化函数Init()里面
m_menubar = wxXmlResource::Get()->LoadMenuBar(wxT("m_menubar1")); SetMenuBar(m_menubar); assert(m_menubar);
这样就可以在菜单中进行相应的操作。如:
m_menuItem=m_menubar->FindItem(wxXmlResource::GetXRCID(wxT("m_menuItem1")));原文链接:https://www.f2er.com/xml/298412.html