我知道文档可以有多个视图 这些可以通过子框架类中的分割器或通过CTabView进行 但我想要多个标签,其中标签包含多个带分割器的视图?
这种组合可能吗?
答案 0 :(得分:1)
CTabCtrl :: InsertItem可以在tabctrl中将视图作为新选项卡插入。
CWnd* CObjectDlg::AddView(LPCTSTR lpszLabel, CRuntimeClass *pViewClass)
{
CCreateContext context;
context.m_pCurrentDoc = NULL;
context.m_pCurrentFrame = GetParentFrame();
context.m_pLastView = NULL;
context.m_pNewDocTemplate = NULL;
context.m_pNewViewClass = pViewClass;
CWnd* pWnd;
TRY {
pWnd = (CWnd*)pViewClass->CreateObject();
if (pWnd == NULL){
AfxThrowMemoryException();
}
}
CATCH_ALL(e) {
TRACE0(_T("Out of memory creating a view.\n"));
return NULL;
}
END_CATCH_ALL
ASSERT_KINDOF(CWnd, pWnd);
ASSERT(pWnd->m_hWnd == NULL); // not yet created
DWORD dwStyle = AFX_WS_DEFAULT_VIEW;
CRect rect;
// Create with the right size and position
if (!pWnd->Create(NULL, NULL, dwStyle, rect, &m_ObjectTab, 0, &context)) {
TRACE0(_T("Warning: couldn't create client pane for view.\n"));
// pWnd will be cleaned up by PostNcDestroy
return NULL;
}
int nViews = m_ObjectTab.GetItemCount();
if (nViews != 0) {
pWnd->EnableWindow(FALSE);
pWnd->ShowWindow(SW_HIDE);
}
else{
pWnd->EnableWindow(TRUE);
pWnd->ShowWindow(SW_SHOW);
m_pActiveView = (CView*)pWnd;
}
TC_ITEM tci;
tci.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
tci.pszText = (LPTSTR)(LPCTSTR)lpszLabel;
tci.iImage = nViews;
tci.lParam = (DWORD)pWnd;
m_ObjectTab.InsertItem(nViews, &tci);
CRect rcChild;
m_ObjectTab.GetClientRect(&rcChild);
rcChild.top += 2;
rcChild.left += 2;
rcChild.bottom -= 23;
rcChild.right -= 2;
pWnd->MoveWindow(rcChild);
m_WndArray.Add(pWnd);
return pWnd;
}