Bonjour,

Je suis entrain de construire une application wxwidgets.

J'utilise les exemples présent dans la partie cour du site.

J'aimerai creer une boite de dialogue personnaliser qui demande le nom de la prénom de la personne ainsi que deux boutons OK et Annuler.

Voici l'exmple du site dans lequel j'aimerai enlever les Radiobouton pour les remplacer par deux wxTextCtrl qui me permettrai d'enregistrer le nom et le prénom de la personne dans deux variables.


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
 
#ifndef wxWinH
#define wxWinH
 
class Application : public wxApp
{
public:
    virtual bool OnInit();
};
//------------------------------------------------------------------------------
class Frame : public wxFrame
{
public:
    Frame(const wxString& title, const wxPoint& pos, const wxSize& size,
                                            long style = wxDEFAULT_FRAME_STYLE);
private:
    int Chiffre; //mémorise le chiffre sélectionné
    wxStaticText *Label;
    void OnQuit(wxCommandEvent& event);
    void OnDialog(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
//------------------------------------------------------------------------------
class Dialog : public wxDialog
{
public:
    Dialog(wxWindow* parent, wxWindowID id, const wxString& title, int nb = 0);
    int GetValue();
    void SetValue(int);
private:
    wxRadioButton *RadioBouton1;
    wxRadioButton *RadioBouton2;
    wxRadioButton *RadioBouton3;
};
//------------------------------------------------------------------------------
enum
{
    App_Quit = 1,
    Menu_dialog
};

#endif //wxWinH
et

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 
#include "wx/wxprec.h"
 
#ifdef __BORLANDC__
    #pragma hdrstop
#endif
 
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif
//------------------------------------------------------------------------------
#include "wxWin.h"
 
BEGIN_EVENT_TABLE(Frame, wxFrame)
    EVT_MENU(App_Quit,  Frame::OnQuit)
    EVT_MENU(Menu_dialog,  Frame::OnDialog)
END_EVENT_TABLE()
 
IMPLEMENT_APP(Application)
 
bool Application::OnInit()
{
    Frame *frame = new Frame("Frame", wxPoint(150, 150), wxSize(480, 220));
    frame->Show();
    return true;
}
 
//------------------------------------------------------------------------------
//LA FENETRE PRINCIPALE
//------------------------------------------------------------------------------
Frame::Frame(const wxString& title, const wxPoint& pos, const wxSize& size,
                        long style) : wxFrame(NULL, -1, title, pos, size, style)
{
    SetIcon(wxICON(monicone));
    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
 
    wxMenu *menuFichier = new wxMenu;
    menuFichier->Append(Menu_dialog,"Dialogue");
    menuFichier->Append(App_Quit,"Quitter l'application");
    wxMenuBar *menuBarre = new wxMenuBar();
    menuBarre->Append(menuFichier,("&Fichier"));
    SetMenuBar(menuBarre);
 
    Label = new wxStaticText(this,-1,"N° Sélectionné : Aucun",wxDefaultPosition,
                           wxSize(-1, 60),wxALIGN_CENTRE | wxST_NO_AUTORESIZE );
    Label->SetFont(wxFont(12, wxSWISS , wxNORMAL, wxBOLD, false, "Arial"));
 
    wxBoxSizer *Psizer = new wxBoxSizer( wxVERTICAL );
    Psizer->Add(-1,60);
    Psizer->Add(Label,0, wxEXPAND );
    SetSizer(Psizer);
 
    Chiffre = 0;
}
//------------------------------------------------------------------------------
void Frame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
     Close();
}
//------------------------------------------------------------------------------
void Frame::OnDialog(wxCommandEvent& WXUNUSED(event))
{
     Dialog dialog(NULL,-1,"Titre",Chiffre);
     if ( dialog.ShowModal() == wxID_OK )
         {
            wxString st = "Aucun";
            Chiffre = dialog.GetValue();
              switch(Chiffre)
               {
                 case 1 : st = "Un";
                          break;
                 case 2 : st = "Deux";
                          break;
                 case 3 : st = "Trois";
                          break;
                }
            Label->SetLabel("N° Sélectionné : " + st);
         }
}
 
//------------------------------------------------------------------------------
//LA BOITE DE DIALOGUE
//------------------------------------------------------------------------------
Dialog::Dialog(wxWindow* parent, wxWindowID id, const wxString& titre, int nb)
                  : wxDialog(parent,id,titre,wxDefaultPosition,wxSize(240, 200))
{
      RadioBouton1 = new wxRadioButton(this,-1,"Un");
      RadioBouton2 = new wxRadioButton(this,-1,"Deux");
      RadioBouton3 = new wxRadioButton(this,-1,"Trois");
      wxButton *MonBouton1 = new wxButton(this,wxID_OK,"Ok");
      wxButton *MonBouton2 = new wxButton(this,wxID_CANCEL,"Annuler");
 
      wxBoxSizer *sizer1 = new wxBoxSizer( wxVERTICAL );
      sizer1->Add(-1,25);
      sizer1->Add(RadioBouton1,0,wxALL,5);
      sizer1->Add(RadioBouton2,0,wxALL,5);
      sizer1->Add(RadioBouton3,0,wxALL,5);
 
      wxBoxSizer *sizer2 = new wxBoxSizer( wxHORIZONTAL );
      sizer2->Add(MonBouton1,0,wxBOTTOM | wxLEFT | wxRIGHT ,5);
      sizer2->Add(MonBouton2,0,wxBOTTOM | wxLEFT | wxRIGHT ,5);
 
      wxBoxSizer *Psizer = new wxBoxSizer( wxVERTICAL );
      Psizer->Add(sizer1,3,wxALIGN_CENTER);
      Psizer->Add(sizer2,1,wxALIGN_CENTER);
      SetSizer(Psizer);
      SetValue(nb);
}
//------------------------------------------------------------------------------
int Dialog::GetValue()
{
      int x = 0;
      if( RadioBouton1->GetValue() ) x = 1;
      if( RadioBouton2->GetValue() ) x = 2;
      if( RadioBouton3->GetValue() ) x = 3;
      return x;
}
//------------------------------------------------------------------------------
void Dialog::SetValue(int x)
{
      switch(x)
       {
        case 1 : RadioBouton1->SetValue(true);
                 break;
        case 2 : RadioBouton2->SetValue(true);
                 break;
        case 3 : RadioBouton3->SetValue(true);
                 break;
        }
}
Je pense qu'il faut que j'utilise Getvalue et Setvalue mais dans cet exemple setValue renvoi un entier alors que je souhaite envoyer des caractères.

Si vous avez des exemples qui ressemblent à ce que je souhaite réaliser.

Merci