此代码完美无缺
myNotebook = new wxNotebook( this, IDC_NOTEBOOK, wxDefaultPosition, wxSize(500, 500) );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 1" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 2" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 3" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 4" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 5" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 6" );
但是,选项卡名称太长且很多,必须水平滚动。
使用wxNB_MULTILINE样式无法正常工作:第二行标签被隐藏且不可读
myNotebook = new wxNotebook( this, IDC_NOTEBOOK, wxDefaultPosition, wxSize(500, 500), wxNB_MULTILINE );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 1" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 2" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 3" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 4" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 5" );
myNotebook->AddPage( new wxNotebookPage( myNotebook, -1 ), L"TEST RECOMMENDATIONS 6" );
如何正确使用多线样式?
答案 0 :(得分:1)
经过实验,我发现了这种方式:
在所有AddPage()调用
之后添加一行 myNotebook->Layout();
答案 1 :(得分:1)
问题似乎是持有笔记本页面的面板覆盖了第二行标签。
我可以通过处理EVT_NOTEBOOK_PAGE_CHANGED
事件并添加此行代码来强制面板移开
myNotebook->GetPage( event.GetSelection() )->Move(0,40);
丑陋,但它确实起作用。
答案 2 :(得分:0)
最后,找到了一个优雅的解决方案。我需要在调整大小后强制刷新。
void MyFrame::OnSize(wxSizeEvent& )
{
if( myNotebook ) {
myNotebook->SetSize( GetClientRect() );
myNotebook->Refresh();
}
}