[wxWidgets] pas de labels
Bonjour à vous
Voici que je me met au C++ et pour être plus précis à wxWidgets 2.6.2 pour X11/Motif sous FedoraCore 3.
Pour mon premier essai, j'ai utilisé le code ô combien classique d'un helloworld :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <wx/wx.h>
class MyApp : public wxApp
{
virtual bool OnInit();
};
IMPLEMENT_APP(MyApp)
class MyFrame : public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
};
enum
{
ID_Quit=1,
ID_About
};
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame("Hello World", wxPoint(50,50),
wxSize(450,350));
frame->Connect( ID_Quit, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) &MyFrame::OnQuit );
frame->Connect( ID_About, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) &MyFrame::OnAbout );
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame*)NULL,-1,title,pos,size)
{
// create menubar
wxMenuBar *menuBar = new wxMenuBar;
// create menu
wxMenu *menuFile = new wxMenu;
// append menu entries
menuFile->Append(ID_About,"&About...");
menuFile->AppendSeparator();
menuFile->Append(ID_Quit,"E&xit");
// append menu to menubar
menuBar->Append(menuFile,"&File");
// set frame menubar
SetMenuBar(menuBar);
// create frame statusbar
CreateStatusBar();
// set statusbar text
SetStatusText("Welcome to wxWindows!");
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox("wxWindows Hello Word example.","About Hello World",
wxOK|wxICON_INFORMATION, this);
} |
Avec la ligne de compilation suivante :
Code:
1 2
|
g++ hello.cpp `wx-config --libs` `wx-config --cxxflags` -o hello |
Or, à l'exécution, ma fenêtre apparaît bien mais je n'ai aucun labl qui apparaît (par exemple, mes menus ne contiennent nullement les labels File ou Quit).
Pourquoi cette anomalie ?
Merci d'avance de vos réponses.
@++