I'm trying to load a menu from an .xrc file. Unfortuately I keep getting errors.
main.cpp
#include <wx/xrc/xmlres.h>
#include "main.h"
int idFileQuit = XRCID("idFileQuit");
int idHelpAbout = XRCID("idHelpAbout");
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
EVT_MENU(idFileQuit, MainFrame::OnQuit)
EVT_MENU(idHelpAbout, MainFrame::OnAbout)
END_EVENT_TABLE()
MainFrame::MainFrame(wxFrame *frame, const wxString& title,
int xpos, int ypos, int width, int height)
: wxFrame(frame, -1, title, wxPoint(xpos, ypos), wxSize(width, height))
{
wxXmlResource::Get()->InitAllHandlers();
wxXmlResource::Get()->Load(_T("/resources.zip#zip*.xrc"));
CreateMenubar();
}
MainFrame::~MainFrame()
{
}
bool MainFrame::CreateMenubar()
{
wxMenuBar* mbar = 0L;
wxXmlResource *myres = wxXmlResource::Get();
myres->Load(_T("/resources.zip#zip:main_menu.xrc"));
myres->LoadMenuBar(0L, _T("main_menu_bar"));
SetMenuBar(mbar);
return true;
}
void MainFrame::OnQuit(wxCommandEvent& event)
{
Close(true);
}
void MainFrame::OnAbout(wxCommandEvent& event)
{
wxMessageBox(_("wxWidgets Example"), _("Welcome to..."));
}
main_menu.xrc
<?xml version="1.0"?>
<resource>
<object class="wxMenuBar" name="main_menu_bar">
<object class="wxMenu" name="file_menu">
<label>&File</label>
<object class="wxMenuItem" name="idFileExit">
<label>&Quit</label>
<accel>Ctrl-Q</accel>
<help>Quit wxWidgets Example</help>
</object>
</object>
<object class="wxMenu" name="help_men">
<label>&Help</label>
<object class="wxMenuItem" name="wxID_ABOUT">
<label>&About...</label>
<help>About wxWidgets Example</help>
</object>
</object>
</object>
</resource>
So wxWidgets tells me "XRC resource 'main_menu_bar' (class 'wxMenuBar') not found!"
It gives me a nice little error box I click on details and it says "can't load resources from file '"/resources.zip#zip:main_menu.xrc' (time)"
It gives me an option to save to a log and here is the log.
16:05:59: Cannot load resources from file '/resources.zip#zip:main_menu.xrc'.
16:05:59: Cannot load resources from file '/resources.zip#zip:main_menu.xrc'.
16:05:59: XRC resource 'main_menu_bar' (class 'wxMenuBar') not found!
What am I doing wrong? This is totally new to me, I have never used wxWidgets before.