1
votes
Dialog::Dialog(const wxString & title): wxDialog(NULL, -1, title, wxDefaultPosition, wxSize(200, 200))
{

  panel = new wxPanel(this, -1);

  wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
  wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);

  wxButton *ab = new wxButton(this, wxID_OK, wxT("a"),
      wxDefaultPosition, wxSize(70, 30));
  wxButton *bb = new wxButton(this, wxID_CANCEL, wxT("b"),
      wxDefaultPosition, wxSize(70, 30));

  hbox->Add(ab, 1);
  hbox->Add(bb,1);

  vbox->Add(panel, 1);
  vbox->Add(hbox, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10);

  SetSizer(vbox);

  Centre();
  ShowModal();

  Destroy();
}

Hi, I want to dynamically on button click add wxStaticText in this wxDialog so each time a button is clicked wxStaticText will be added in different location, How can I do that? Thanks for your help.

1
You need to try doing it and then tell us what problems did you encounter (normally there should be none). - VZ.
How to redraw the wxDialog? - Neet33

1 Answers

1
votes

If you add or remove controls to a window, you need to re-layout it using either wxSizer::Layout() or wxWindow::Layout() which forwards to the former for the window sizer.