Pessoal, eu estou fazendo uma aplicação em C++ com wxWidgets. Na aplicação eu fiz um menu mas mesmo com o código correto, o menu não aparece no frame. Alguém sabe o que fazer?
MenuMain.cpp:
#include "MenuMain.h"
#include <wx/msgdlg.h>
#include <wx/string.h>
#include <wx/intl.h>
enum wxbuildinfoformat {short_f, long_f};
wxString wxbuildinfo(wxbuildinfoformat format){
wxString wxbuild(wxVERSION_STRING);
if(format == long_f){
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif
}
return wxbuild;
}
const long MenuFrame::ID_PANEL1 = wxNewId();
const long MenuFrame::idMenuQuit = wxNewId();
const long MenuFrame::idMenuAbout = wxNewId();
const long MenuFrame::ID_STATUSBAR1 = wxNewId();
BEGIN_EVENT_TABLE(MenuFrame,wxFrame)
END_EVENT_TABLE()
MenuFrame::MenuFrame(wxWindow* parent,wxWindowID id){
wxMenuItem* MenuItem2;
wxMenuItem* MenuItem1;
wxMenu* Menu1;
wxMenuBar* MenuBar1;
wxMenu* Menu2;
Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
SetClientSize(wxSize(635,437));
Panel1 = new wxPanel(this, ID_PANEL1, wxPoint(352,152), wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
MenuBar1 = new wxMenuBar();
Menu1 = new wxMenu();
MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
Menu1->Append(MenuItem1);
MenuBar1->Append(Menu1, _("&File"));
Menu2 = new wxMenu();
MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
Menu2->Append(MenuItem2);
MenuBar1->Append(Menu2, _("Help"));
SetMenuBar(MenuBar1); //Era para o menu ser exibido com este comando
StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
int __wxStatusBarWidths_1[1] = { -1 };
int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
SetStatusBar(StatusBar1);
Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MenuFrame::OnQuit);
Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MenuFrame::OnAbout);
Center();
SetTitle("Menu");
}
MenuMain.h:
#ifndef MENUMAIN_H
#define MENUMAIN_H
#include <wx/menu.h>
#include <wx/panel.h>
#include <wx/statusbr.h>
#include <wx/frame.h>
class MenuFrame: public wxFrame{
public:
MenuFrame(wxWindow* parent,wxWindowID id = -1);
virtual ~MenuFrame();
private:
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
static const long ID_PANEL1;
static const long idMenuQuit;
static const long idMenuAbout;
static const long ID_STATUSBAR1;
wxPanel* Panel1;
wxStatusBar* StatusBar1;
DECLARE_EVENT_TABLE()
};
#endif
MenuApp.h:
#include "MenuApp.h"
#include "MenuMain.h"
#include <wx/image.h>
IMPLEMENT_APP(MenuApp);
bool MenuApp::OnInit(){
bool wxsOK = true;
wxInitAllImageHandlers();
if( wxsOK ){
MenuFrame* Frame = new MenuFrame(0);
Frame->Show();
SetTopWindow(Frame);
}
return wxsOK;
}
MenuApp.h:
#ifndef MENUAPP_H
#define MENUAPP_H
#include <wx/app.h>
class MenuApp : public wxApp{
public:
virtual bool OnInit();
};
#endif