bonjour,
je debute en c++ et je suis entrain de faire un petit prog d'aprentissage sans pretantion avec wxwindows.
mais je bloque a un endroit:

base.h:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
#ifndef __BASE_H
#define __BASE_H
 
class MainApp: public wxApp
{
  public:
      virtual bool OnInit();
};
 
class MainFrame: public wxFrame
{
  public:
      MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size);
      void OnQuit(wxCommandEvent &event);
      void Envoyer(wxCommandEvent &event);
      wxTextCtrl *text;
      wxTextCtrl *Form;
      wxButton *bouton;
  private:
      DECLARE_EVENT_TABLE()
};
 
enum
{
   ID_MAINWIN_QUIT = wxID_HIGHEST+1,
   BOUTON_ENVOYER,
};
 
 
#endif
base.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
#include <wx/wxprec.h>
#include <wx/textctrl.h>
#ifndef WX_PRECOMP
   #include <wx/wx.h>
#endif
 
#include "base.h"
#include <string>
 
IMPLEMENT_APP(MainApp)
 
bool MainApp::OnInit()
{
   MainFrame *win = new MainFrame("chat", wxPoint (100, 100),
     wxSize(450, 340));
   win->Show(TRUE);
   SetTopWindow(win);
 
   return TRUE;
}
 
 
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
   EVT_MENU(ID_MAINWIN_QUIT, MainFrame::OnQuit)
   EVT_BUTTON(BOUTON_ENVOYER, MainFrame::Envoyer)
END_EVENT_TABLE()
 
MainFrame::MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
    : wxFrame((wxFrame *) NULL, -1, title, pos, size)
{    
    wxTextCtrl *Text = new wxTextCtrl(this, -1, wxEmptyString, wxPoint(0,0), wxSize(450,250), wxTE_MULTILINE);
    Text->SetEditable(false);
 
    wxTextCtrl *Form = new wxTextCtrl(this, -1, wxEmptyString, wxPoint(0,250), wxSize(350,30), wxTE_MULTILINE);
    Form->SetEditable(true);
 
    wxButton *bouton = new wxButton(this, BOUTON_ENVOYER, "envoyer" , wxPoint(360,250));
 
}
 
void MainFrame::OnQuit(wxCommandEvent & WXUNUSED(event))
{
    Close(TRUE);
}
 
void MainFrame::Envoyer(wxCommandEvent & WXUNUSED(event))
{
     wxString valeur;
     valeur=Form->GetValue();
     Text->WriteText(valeur);
}
le prog compile mais lorsque je clique sur le bouton, il quitte.
c'est donc la fonctionMainFrame::Envoyer qui cloche mais je n'arrive pas a trouver comment y remedier.
savez vous ce qui ne va pas ?