if I add a panel to it's parent window without set the size of this panel, how to knonw its actual size?
wxBoxSizer * vSizer = parent->GetSizer();
wxPanel * subPanel = new wxPanel(parent, "Ok", wxID_ANY, wxDefaultPosition, wxDefaultSize);
vSizer ->Add(subPanel, 0, wxEXPAND | wxALL);
wxSize sz = subPanel->GetSize();
int height = sz.GetHeight();
but hieght is always 0.
How to get the actual size of panel?
Re: How to get the actual size of panel?
I think the sizer needs to get laid out first, after the window it belongs to is displayed/sized. In your code is probably had not yet.
Re: How to get the actual size of panel?
Thanks PB!
The real things is something complicated.
I created a panel and add this panel to a wxAuiManager. Although I set a initial size for this parent panel, but the real size should be larger than the initial size because of stretch by AUI manager.
After main GUI display done, I want to get the real size of ParentPanel but the height is always 0.
The real things is something complicated.
I created a panel and add this panel to a wxAuiManager. Although I set a initial size for this parent panel, but the real size should be larger than the initial size because of stretch by AUI manager.
Code: Select all
wxPanel *topPanel = new wxPanel(mainFrame); //it's child of main frame
wxAuiManager * PAuiManager = new wxAuiManager(topPanel, wxAUI_MGR_DEFAULT | wxAUI_MGR_TRANSPARENT_DRAG);
//create system panel at the right side of main frame
ParentPanel = new wxPanel(topPanel , wxString("SystemPanel")); assert(ParentPanel != NULL);
ParentPanel->SetSize(220, 308);
wxAuiPaneInfo PaneInfo;
PaneInfo.Right();
PaneInfo.CloseButton(false);
PaneInfo.PinButton(false);
PaneInfo.PaneBorder(false);
PaneInfo.MinimizeButton(false);
PaneInfo.MaximizeButton(false);
PaneInfo.BottomDockable(false);
PaneInfo.TopDockable(false);
PaneInfo.LeftDockable(false);
PaneInfo.Layer(2).Position(1);
PaneInfo.Caption(wxT("System")).CaptionVisible(false);
PaneInfo.Name(wxT("System"));
PaneInfo.MinSize(w, -1);
PaneInfo.MaxSize(w, -1);
PAuiManager->InsertPane(ParentPanel, PaneInfo);
wxBoxSizer* gs = new wxBoxSizer(wxVERTICAL);
ParentPanel->SetSizer(gs);
ParentPanel->Layout();
//create other panels and insert into AuiManager
...
Re: How to get the actual size of panel?
forgive my stupid, I hiden the panel in another place, so the size is always zero.