0

I am new to C::B and wxWidgets. I've tried to create a simple screen like this:

enter image description here

But I get this when it's run:

enter image description here

I have changed a few properties like the following but I'm not sure if this was the right thing to do.

  1. I placed a flex grid on the form. Made it for 1 column and 3 rows
  2. Placed 3 BoxSizers. So they're one under the other. Set the expand property to true.
  3. Placed StaticText and TextCtrl elements (one each) in the first 2 boxer sizers
  4. Placed a spacer and Button in the 3rd box sizer
  5. For the address text box, I set the multiline property to true (check box) 5.

But when run, it does not seem to grow. The button is missing at the bottom.

Any ideas on how to fix this please... Thanks!

Here's (part of) the default code that was generated for the form.

KBond::KBond(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
    //(*Initialize(KBond)
    wxBoxSizer* BoxSizer2;
    wxBoxSizer* BoxSizer1;
    wxFlexGridSizer* FlexGridSizer1;
    wxBoxSizer* BoxSizer3;

    Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER, _T("wxID_ANY"));
    SetClientSize(wxSize(520,300));
    FlexGridSizer1 = new wxFlexGridSizer(3, 1, 0, 0);
    BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
    StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Enter your name"), wxDefaultPosition, wxSize(90,27), 0, _T("ID_STATICTEXT1"));
    BoxSizer1->Add(StaticText1, 1, wxALL|wxSHAPED|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
    TextCtrl1 = new wxTextCtrl(this, ID_TEXTCTRL1, _("Text"), wxDefaultPosition, wxSize(148,27), 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
    BoxSizer1->Add(TextCtrl1, 2, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    FlexGridSizer1->Add(BoxSizer1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
    StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Address"), wxDefaultPosition, wxSize(122,22), 0, _T("ID_STATICTEXT2"));
    BoxSizer2->Add(StaticText2, 1, wxALL|wxALIGN_TOP|wxALIGN_CENTER_HORIZONTAL, 5);
    TextCtrl2 = new wxTextCtrl(this, ID_TEXTCTRL2, _("Text"), wxDefaultPosition, wxSize(113,98), wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL2"));
    BoxSizer2->Add(TextCtrl2, 2, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    FlexGridSizer1->Add(BoxSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    BoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
    BoxSizer3->Add(0,0,2, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    Button1 = new wxButton(this, ID_BUTTON1, _("Label"), wxDefaultPosition, wxSize(62,29), 0, wxDefaultValidator, _T("ID_BUTTON1"));
    Button1->SetMaxSize(wxSize(0,0));
    BoxSizer3->Add(Button1, 1, wxALL|wxSHAPED|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
    FlexGridSizer1->Add(BoxSizer3, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    SetSizer(FlexGridSizer1);
    FlexGridSizer1->SetSizeHints(this);

    Connect(wxID_ANY,wxEVT_INIT_DIALOG,(wxObjectEventFunction)&KBond::OnInit);
    //*)
}
itsols
  • 5,406
  • 7
  • 51
  • 95

1 Answers1

1

This looks like it would give your trouble:

 Button1->SetMaxSize(wxSize(0,0));
ravenspoint
  • 19,093
  • 6
  • 57
  • 103
  • Well caught! +1 for direction... Thanks for that. But I think I've bumped into a new issue... I removed the button from the form. Now it doesn't compile. It Connect(wxID_ANY,wxEVT_INIT_DIALOG,(wxObjectEventFunction)&KBond::OnInit); But when I comment the last line (i.e., Connect(wxID....) it compiles fine. What seems to be the issue? BTW, by removing the button, the relevant code was auto-removed. – itsols May 21 '13 at 12:49
  • I removed that line of code (took some risk there - smiles) and put in another button on the form. Even added an "OnClick" event and it seems to work. So I guess it was redundant code that was left out byt the C::B IDE. Thanks for your time! – itsols May 21 '13 at 12:53
  • You are welcome. For my own take on C:B and similar tools see this answer: http://stackoverflow.com/a/13440487/16582 – ravenspoint May 21 '13 at 13:05