尝试使用 DialogBlocks 并查看它生成的代码以了解 grid bag sizer 的使用工作流程。
void Yarrr1::CreateControls()
{
////@begin Yarrr1 content construction
Yarrr1* itemPanel1 = this;
wxGridBagSizer* itemGridBagSizer2 = new wxGridBagSizer(0, 0);
itemGridBagSizer2->SetEmptyCellSize(wxSize(10, 20));
itemPanel1->SetSizer(itemGridBagSizer2);
wxButton* itemButton3 = new wxButton( itemPanel1, ID_BUTTON6, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
itemGridBagSizer2->Add(itemButton3, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton4 = new wxButton( itemPanel1, ID_BUTTON7, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
itemGridBagSizer2->Add(itemButton4, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
////@end Yarrr1 content construction
}
产生http://screencast.com/t/mANmpGmGb20