Bonjour,

ça fait un moment que je fais des tentatives, et je dois dire que je n'arrive toujours pas à comprendre le fonctionnement...

Voici mon petit problème :

J'ai un sizer contenant 2 autres contrôles. Je voudrais que,
  • lors de l'appel d'une fonction, que les 2 contrôles s'affichent correctement (tel que lors de la construction) ;
  • lors de l'appel d'une seconde fonction, que l'un des 2 contrôles disparaisse, laissant toute la place au contrôle restant.


Pas moyen de redimensionner le contrôle restant. L'un des contrôle disparaît mais le contrôle restant ne se redimensionne pas

Voici le code que j'ai utilisé (et quelques tentatives qui n'ont rien données...):
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
 
//--------------------------------------------------------------
class wxTestLayoutFrame: public wxFrame
{
    public:
        wxTestLayoutFrame(wxFrame *frame, const wxString& title);
        ~wxTestLayoutFrame();
 
    private:
      wxBoxSizer *m_mainSizer;
      wxStaticBoxSizer *m_sizer1;
      wxStaticBoxSizer *m_sizer2;
 
      enum
      {
          idMenuLayout1 = 1000,
          idMenuLayout2,
      };
      void OnLayout1(wxCommandEvent& event);
      void OnLayout2(wxCommandEvent& event);
 
      DECLARE_EVENT_TABLE()
};
//--------------------------------------------------------------
BEGIN_EVENT_TABLE(wxTestLayoutFrame, wxFrame)
    EVT_MENU(idMenuLayout1, wxTestLayoutFrame::OnLayout1)
    EVT_MENU(idMenuLayout2, wxTestLayoutFrame::OnLayout2)
END_EVENT_TABLE()
 
//--------------------------------------------------------------
wxTestLayoutFrame::wxTestLayoutFrame(wxFrame *frame, const wxString& title)
    : wxFrame(frame, -1, title)
{
    //Création de la barre de menus
      wxMenu* helpMenu = new wxMenu(_T(""));
        helpMenu->Append(idMenuLayout1, _("Layout 1\tF1"));
        helpMenu->Append(idMenuLayout2, _("Layout 2\tF2"));
 
      wxMenuBar* mbar = new wxMenuBar();
        mbar->Append(helpMenu, _("&Layout"));
        SetMenuBar(mbar);
 
    //Création des contrôles
      m_sizer1 = new wxStaticBoxSizer(wxVERTICAL, this, _("Sizer 1"));
      m_sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, _("Sizer 2"));
 
      m_mainSizer = new wxBoxSizer(wxHORIZONTAL);
        m_mainSizer->Add(m_sizer1, 1, wxALL | wxEXPAND, 5);
        m_mainSizer->Add(m_sizer2, 1, wxALL | wxEXPAND, 5);
 
      SetSizer(m_mainSizer);
}
//--------------------------------------------------------------
wxTestLayoutFrame::~wxTestLayoutFrame()
{
}
//--------------------------------------------------------------
void wxTestLayoutFrame::OnLayout1(wxCommandEvent& event)
{
  wxMessageBox(_("Layout 1"));
 
    m_mainSizer->Show(m_sizer2);
//    Layout();
//    m_mainPanel->Layout();
//    Show();
    InvalidateBestSize();
//    FitInside();
}
//--------------------------------------------------------------
void wxTestLayoutFrame::OnLayout2(wxCommandEvent& event)
{
  wxMessageBox(_("Layout 2"));
 
    m_mainSizer->Hide(m_sizer2);
//    m_sizer2->Show(false);
//    m_mainSizer->Clear(false);
//    m_mainSizer->Add(m_sizer1, 1, wxALL | wxEXPAND, 5);
//    Layout();
//    m_mainPanel->Layout();
//    m_mainPanel->Show();
    InvalidateBestSize();
//    FitInside();
}
//--------------------------------------------------------------
Si une âme charitable aurait une idée pour me dépatouillée, ce serai cool, car je sèche un peu

Merci !