我已经使用CSplitterWnd创建了一个mfc对话框,其中有三个不同的面板,如下所示:
BOOL CUserSplit::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
WINDOWPLACEMENT wpDlg;
GetWindowPlacement(&wpDlg);
if (!m_wndSplitter.CreateStatic(this, 1, 3, WS_CHILD | WS_VISIBLE | WS_BORDER))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CSearchDlg), CSize(250, 0), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CProfileDlg), CSize(870, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
if (!m_wndSplitter.CreateView(0, 2, RUNTIME_CLASS(CControlDlg), CSize(0, 0), pContext))
{
TRACE0("Failed to create third pane\n");
return FALSE;
}
SetWindowPos(NULL, 0, 0, 1285, 900, SWP_NOZORDER | SWP_NOMOVE);
GetParentFrame()->CenterWindow();
return TRUE;
}
这样做时,第一个面板在加载时处于活动状态。如何将第二个(中间)面板设置为活动状态?
答案 0 :(得分:3)
您可以像这样在指定位置获取视图:
CView* pView = (CView *)m_pWndSplitter->GetDlgItem(m_pWndSplitter->IdFromRowCol(0, 0));
之后只需致电
SetActiveView(pView);
您也可以尝试使用以下方法:
m_pWndSplitter->SetActivePane(nRow, nCol);
答案 1 :(得分:1)
根据MSDN,您应该致电CSplitterWnd::SetActivePane()