title: wxWidgets Sizers: How to get sizers to behave properly on resize
body: <p>I am currently learning to use wxWidgets in Microsoft Visual Studio C++, and I think that I have my head wrapped around the concept of Sizers.  However, I can't seem to get them to behave how I want them to while resizing.  I am following a tutorial (the link to which I seem to have misplaced, but it is pretty simple), which aims to create a dialog window with an expandable text box and two buttons beneath it which should stay approximately centered.  My code for the window is below, found within the constructor of my dialog window:</p>
  
  <pre><code>vertSizer = new wxBoxSizer(wxVERTICAL); // Create vertical (parent) sizer, will contain text box and child sizer
  vertSizer-&gt;Add(
      new wxTextCtrl(this, -1, "My text", wxDefaultPosition, wxSize(100,80), wxTE_MULTILINE),
      1, // vertically stretchable
      wxEXPAND | wxALL, // horizontally stretchable, borders all around
      10); // Add text box to parent sizer
  
  horizSizer = new wxBoxSizer(wxHORIZONTAL); // Make child sizer, will contain buttons
  wxSizerFlags ButtonFlags(1); // Make controls stretch hoizontally (to cover entire sizer area)
  ButtonFlags.Expand().Center().Border(wxALL,10); // Make controls expand vertically, add border
  horizSizer-&gt;Add(new wxButton(this,wxID_OK,"OK"), ButtonFlags); // Add first button
  horizSizer-&gt;Add(new wxButton(this, ID_Cancel,"Cancel"), ButtonFlags); // Add second button
  
  vertSizer-&gt;Add(horizSizer); // Add child sizer to parent sizer
  SetSizerAndFit(vertSizer);
  </code></pre>
  
  <p>The displayed window looks correct (a large text box on the top portion of the window, with two properly spaced buttons, side-by-side, below it).  However, when the window is resized, the text box expands both vertically and horizontally (expected behavior), but the buttons stay in place, left-aligned (unwanted behavior). (I apologize for not being able to post a picture; I have a couple prepared, but I can't post them with as little reputation as I have.)</p>
  
  <p>The formatting on initialization great, however I would to maintain that formatting while resizing.  Meaning, I want the two buttons beneath the text box to stay in the middle of the window, still side-by-side (although, it's acceptable for the distance between them to increase as the window gets bigger).  Alternatively, I would like the buttons to increase in size horizontally, so that each button takes up half of the area beneath the text box.</p>
  
  <p>I apologize if a similar question has already been asked, but I haven't found a satisfactory answer on this site in my research.</p>
  
  <p>Any help with this would be greatly appreciated.  Thank you!</p>