I have a wxBoxSizer that I dynamically fill with some buttons.
The buttons are displayed without any problem.
Next I perform some action in the program (fired by a click event) that is supposed to remove these buttons and place different buttons instead.
After this action nothing happens or changes....
However, when I change the size of the main window the new buttons suddenly appear (together with the original buttons).
I searched the docs and found that I need to call the Layout() method of wxBoxSizer to force a refresh. So I added this but again no changes..
The following code is the skeleton with non relevant code removed:
Code: Select all
previewFrame::previewFrame(wxWindow* parent,wxWindowID id) {
wxBoxSizer *mainSizer = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *vertSizer = new wxBoxSizer(wxVERTICAL);
mainSizer->Add(vertSizer, 1, wxALL | wxEXPAND, 1);
wxBoxSizer *renderers = new wxBoxSizer(wxHORIZONTAL);
for (int i = 0; i < 5]; i++) {
renderers->Add(button[i], 0, wxEXPAND, 1); // button[] is an array with bitmap-buttons
}
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(renderers, 0, wxALIGN_LEFT, 0);
vertsizer->Add(sizer, 0, wxALIGN_BOTTOM, 0);
this->SetSizer(mainSizer);
}
// called by another button (code not shown)
void myButton::OnClick(wxCommandEvent& event) {
boxsizer->Clear();
for (int i = 5; i < 10; i++) {
boxsizer->Add(button[i], 0, wxEXPAND, 0);
}
boxsizer->Layout();
}
What am I doing wrong?