15,979
社区成员
发帖
与我相关
我的任务
分享
在APP.CPP文件中
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_LTSWCtrlCenterTYPE,
RUNTIME_CLASS(CLTSWCtrlCenterDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CTabView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
BOOL CMainFrame::OnCreateClientView(UINT nID)
{
CCreateContext context;
// POSITION pos = theApp.GetFirstDocTemplatePosition();
// CDocTemplate* pDocTpl = theApp.GetNextDocTemplate(pos);
// if(!pDocTpl)
// return FALSE;
// POSITION posDoc = pDocTpl->GetFirstDocPosition();
// CDocument* pDoc =pDocTpl->GetNextDoc(posDoc);
// if(!pDoc)
// return FALSE;
// context.m_pCurrentDoc = RUNTIME_CLASS(CLTSWCtrlCenterDoc);
//
// CXTPTabManagerItem* pItem = m_MTIClientWnd.HitTest(point);
// CFrameWnd* pFrame = DYNAMIC_DOWNCAST(CMDIChildWnd, CWnd::FromHandle(pItem->GetHandle()));
POSITION pos = theApp.GetFirstDocTemplatePosition();
CDocTemplate* pDocTmp = theApp.GetNextDocTemplate(pos);
if(pDocTmp == NULL)
return FALSE;
CMDIChildWnd* pChild=MDIGetActive();
CMDIFrameWnd* pFrame = (CMDIFrameWnd*)GetActiveFrame();
CLTSWCtrlCenterDoc* pDoc = new CLTSWCtrlCenterDoc();//GetActiveDocument();//MDIGetActive()->GetActiveView()->GetDocument();
// pDocTmp->CreateNewFrame(pDoc,pFrame);
context.m_pCurrentDoc =pDoc;
CView* pView;
if(!CheckID(nID)) //说明未打开过
{
CChildFrame* pFrm = new CChildFrame();
switch (nID)
{
case IDS_STRING_CONTACT:
// pView = (CView*)new CViewOne;
context.m_pNewViewClass = RUNTIME_CLASS(CViewOne);
break;
case IDS_STRING_GROUPLIST:
// pView = (CView*)new CViewTwo;
context.m_pNewViewClass = RUNTIME_CLASS(CViewTwo);
break;
case IDS_STRING_GPS:
// pView = (CView*)new CTabView;
context.m_pNewViewClass = RUNTIME_CLASS(CTabView);
break;
}
// pView->Create(NULL,NULL,0L,CFrameWnd::rectDefault,pFrm,nID,&context);
// context.m_pNewViewClass = pView->GetRuntimeClass();
context.m_pCurrentFrame = pFrm;
pFrm->LoadFrame(IDR_MAINFRAME,
WS_CHILD|WS_OVERLAPPEDWINDOW,this,&context);
pFrm->ShowWindow(SW_SHOW);
pFrm->InitialUpdateFrame(pDoc,TRUE);
AddID(nID,pFrm->GetSafeHwnd());
// pView->OnInitialUpdate();
}
else //已经打开了
{
HWND hwnd = GetHwndFromID(nID);
if (hwnd != NULL)
{
CFrameWnd* pFrm = DYNAMIC_DOWNCAST(CMDIChildWnd, CWnd::FromHandle(hwnd));
if(!pFrm)
return FALSE;
MDIActivate(pFrm);
m_MTIClientWnd.Refresh();
return TRUE;
}
return FALSE;
}
return TRUE;
}
BOOL CMainFrame::OnCreateClientView(UINT nID)
{
CCreateContext context;
POSITION pos = theApp.GetFirstDocTemplatePosition();
CDocument* pDoc;
CView* pView;
CDocTemplate* pDocTmp = (CDocTemplate*)theApp.GetNextDocTemplate(pos);
if(pDocTmp == NULL)
return FALSE;
if(!CheckID(nID)) //说明未打开过
{
switch (nID)
{
case IDS_STRING_CONTACT:
pView = (CView*)new CContactView;
// context.m_pNewViewClass = RUNTIME_CLASS(CViewOne);
break;
case IDS_STRING_GROUPLIST:
pView = (CView*)new CViewTwo;
// context.m_pNewViewClass = RUNTIME_CLASS(CViewTwo);
break;
case IDS_STRING_GPS:
pView = (CView*)new CLTSWCtrlCenterView;
// context.m_pNewViewClass = RUNTIME_CLASS(CTabView);
break;
}
pDoc = pDocTmp->CreateNewDocument();
CChildFrame* pFrm = (CChildFrame*)pDocTmp->CreateNewFrame(pDoc,NULL);
pView->Create(NULL,NULL,0L,CFrameWnd::rectDefault,pFrm,AFX_IDW_PANE_FIRST,NULL);
ASSERT(pView);
pDoc->AddView(pView);
pDocTmp->InitialUpdateFrame(pFrm,pDoc);
RecalcLayout();
AddID(nID,pFrm->GetSafeHwnd());
}
else //已经打开了
{
HWND hwnd = GetHwndFromID(nID);
if (hwnd != NULL)
{
CFrameWnd* pFrm = DYNAMIC_DOWNCAST(CMDIChildWnd, CWnd::FromHandle(hwnd));
if(!pFrm)
return FALSE;
MDIActivate(pFrm);
return TRUE;
}
return FALSE;
}
return TRUE;
}