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
| #include <wx/wx.h>
class FenetrePrincipale : public wxFrame
{
public:
FenetrePrincipale(const wxString & titre,
const wxPoint & position,
const wxSize & taille,
long style = wxDEFAULT_FRAME_STYLE);
void OnOk(wxCommandEvent & event);
private:
wxTextCtrl * Saisie;
DECLARE_EVENT_TABLE()
};
class Application : public wxApp
{
public:
virtual bool OnInit()
{
FenetrePrincipale *fenetre = new FenetrePrincipale(wxT("Test"), wxPoint(-1, -1), wxSize(800, 600));
fenetre->Show(true);
return true;
}
};
IMPLEMENT_APP(Application)
BEGIN_EVENT_TABLE(FenetrePrincipale, wxFrame)
EVT_BUTTON(wxID_OK, FenetrePrincipale::OnOk)
END_EVENT_TABLE()
FenetrePrincipale::FenetrePrincipale(const wxString& titre,
const wxPoint& position,
const wxSize& taille,
long style) :
wxFrame(NULL, -1, titre, position, taille, style)
{
this->Saisie = new wxTextCtrl(this, -1);
wxButton * Ok = new wxButton(this, wxID_OK);
wxBoxSizer * sizerP = new wxBoxSizer(wxVERTICAL);
sizerP->Add(Saisie, 0, wxALL | wxALIGN_CENTER, 10);
sizerP->Add(Ok, 0, wxALL | wxALIGN_CENTER, 10);
SetSizer(sizerP);
}
void FenetrePrincipale::OnOk(wxCommandEvent & WXUNUSED(event))
{
wxString Avant = this->Saisie->GetValue();
wxMessageBox(Avant, wxT("Avant, tout va bien"));
wxString Apres(Avant.mb_str(), wxConvUTF8);
wxMessageBox(Apres, wxT("Apres... rien ne va plus"));
} |
Partager