我遇到了wxScrolledWindow的问题。
我有一个ScrolledWindow持有一个wxListBox。
有效的行为:
在向列表框添加项目时,最终会显示滚动条。
失败的行为:
wxListBox有一些项目。当我减小ScrolledWindow的大小以使某些项被遮挡时,滚动条无法显示。
// split window into 2
wxBoxSizer *sizermain = new wxBoxSizer(wxVERTICAL);
wxSplitterWindow *splittermain = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE);
splittermain->SetSashGravity(0.5);
splittermain->SetMinimumPaneSize(20);
sizermain->Add(splittermain, 1,wxEXPAND,0);
this->SetSizer(sizermain);
// split left window into 2
wxSplitterWindow * splitterleft = new wxSplitterWindow(splittermain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE);
splitterleft->SetSashGravity(0.5);
splitterleft->SetMinimumPaneSize(20);
wxBoxSizer * sizerleft = new wxBoxSizer(wxHORIZONTAL);
sizerleft->Add(splitterleft, 1, wxEXPAND, 0);
// split right window into 2
wxSplitterWindow * splitteright = new wxSplitterWindow(splittermain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE);
splitteright->SetSashGravity(0.5);
splitteright->SetMinimumPaneSize(20);
wxBoxSizer * sizerright = new wxBoxSizer(wxHORIZONTAL);
sizerright->Add(splitteright, 1, wxEXPAND, 0);
wxScrolledWindow *tlpnl = new wxScrolledWindow(splitterleft, wxID_ANY);
wxListBox *tlcalls = new wxListBox(tlpnl, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_EXTENDED);
wxBoxSizer *tlsizer = new wxBoxSizer(wxVERTICAL);
tlsizer->Add(tlcalls, 1,wxEXPAND,0);
tlpnl->SetSizer(tlsizer);
wxScrolledWindow *blpnl = new wxScrolledWindow(splitterleft, wxID_ANY);
wxListBox *blcontacts = new wxListBox(blpnl, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_EXTENDED);
wxBoxSizer *blsizer = new wxBoxSizer(wxVERTICAL);
blsizer->Add(blcontacts, 1,wxEXPAND,0);
blpnl->SetSizer(blsizer);
wxScrolledWindow *trpnl = new wxScrolledWindow(splitteright, wxID_ANY);
inCall = new wxListBox(trpnl, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_EXTENDED);
wxBoxSizer *trsizer = new wxBoxSizer(wxVERTICAL);
trsizer->Add(inCall, 1,wxEXPAND,0);
trpnl->SetSizer(trsizer);
wxScrolledWindow *brpnl = new wxScrolledWindow(splitteright, wxID_ANY);
wxTextCtrl *brtext = new wxTextCtrl(brpnl, wxID_ANY);
wxBoxSizer *brsizer = new wxBoxSizer(wxVERTICAL);
brsizer->Add(brtext, 1,wxEXPAND,0);
brpnl->SetSizer(brsizer);
splittermain->SplitVertically(splitterleft, splitteright);
splitterleft->SplitHorizontally(tlpnl, blpnl);
splitteright->SplitHorizontally(trpnl, brpnl);
答案 0 :(得分:0)
您的代码似乎没有显示问题(因为任何地方都没有项目),但至少有一个问题:您创建sizerLeft
和sizerRight
sizer并添加内容但他们自己从不使用这些尺寸。这可能解释了布局问题...但如果没有,你真的应该显示实际显示你正在描述的问题的代码(并且可能比你所拥有的更短,实际上是否需要拆分器?)。