CDocument* CChkworkApp::CreateNewFrameViewDoc(CChkworkDocTemplate* pDocTemplate)
{
POSITION posDoc=pDocTemplate->GetFirstDocPosition();
CDocument* pDocument =NULL;
if(posDoc!=NULL){
pDocument =pDocTemplate->GetNextDoc(posDoc);
//To get the first view in the list of views: POSITION posView = pDocument ->GetFirstViewPosition();
CView* pFirstView = pDocument ->GetNextView(posView);
// This example uses CDocument::GetFirstViewPosition
// and GetNextView to repaint each view.
ASSERT(pFirstView !=NULL);
pFirstView ->GetParentFrame()->GetLastActivePopup()->BringWindowToTop();
return pDocument;
}
else{
pDocument =pDocTemplate->CreateNewDocument();
if (pDocument == NULL)
{
TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
return NULL;
}
ASSERT_VALID(pDocument);
CString strTitle;
pDocTemplate->GetDocString(strTitle,CDocTemplate::windowTitle);
pDocument->SetTitle(strTitle);
BOOL bAutoDelete = pDocument->m_bAutoDelete;
pDocument->m_bAutoDelete = FALSE; // don't destroy if something goes wrong
CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(pDocument, NULL);
pDocument->m_bAutoDelete = bAutoDelete;
if (pFrame == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
delete pDocument; // explicit delete on error
return NULL;
}
ASSERT_VALID(pFrame);
pDocTemplate->InitialUpdateFrame(pFrame ,pDocument,TRUE);
pFrame->ShowWindow(SW_SHOWMAXIMIZED);
}
return pDocument ;
}
{
POSITION posDoc=pDocTemplate->GetFirstDocPosition();
CDocument* pDocument =NULL;
if(posDoc!=NULL){
pDocument =pDocTemplate->GetNextDoc(posDoc);
//To get the first view in the list of views: POSITION posView = pDocument ->GetFirstViewPosition();
CView* pFirstView = pDocument ->GetNextView(posView);
// This example uses CDocument::GetFirstViewPosition
// and GetNextView to repaint each view.
ASSERT(pFirstView !=NULL);
pFirstView ->GetParentFrame()->GetLastActivePopup()->BringWindowToTop();
return pDocument;
}
else{
pDocument =pDocTemplate->CreateNewDocument();
if (pDocument == NULL)
{
TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
return NULL;
}
ASSERT_VALID(pDocument);
CString strTitle;
pDocTemplate->GetDocString(strTitle,CDocTemplate::windowTitle);
pDocument->SetTitle(strTitle);
BOOL bAutoDelete = pDocument->m_bAutoDelete;
pDocument->m_bAutoDelete = FALSE; // don't destroy if something goes wrong
CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(pDocument, NULL);
pDocument->m_bAutoDelete = bAutoDelete;
if (pFrame == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
delete pDocument; // explicit delete on error
return NULL;
}
ASSERT_VALID(pFrame);
pDocTemplate->InitialUpdateFrame(pFrame ,pDocument,TRUE);
pFrame->ShowWindow(SW_SHOWMAXIMIZED);
}
return pDocument ;
}
解决方案 »
- PCI1710.exe 中的 0x0041f5b5 处未处理的异常: 0xC0000005: 写入位置 0x00000000 时各位大大 帮我看看这块要怎么弄
- 怎样动态显示一个进度对话框呢?
- 关于CDaoDatabase的问题?
- 用Directx开发的程序,用户在安装时也必须安装Directx吗?
- 请问CDatabase类里面的Open方法如何传入连接数据库的用户名和密码?
- 用VC编程安装.inf文件的问题
- 模拟鼠标拖放url到ie
- 内码转换的问题(GB、BIG5、UNICODE)?
- 请问哪里有不要钱的visual studio .net beta2下载,谢谢各位!
- 菜鸟问题:大家看看我写的建立链表的程序对不对,送分了
- 请问怎样得到FlexGrid控件,鼠标击中的表格项的行宽width和行高height,以及该表格项左上角在对话框客户区上的屏幕坐标x和y值。
- 请问在vc中怎样才能多行读取数据库的文件?
能写的更详细一点吗?CChkworkDocTemplate好象是你自己建立的,我不能看懂。
1寻找当前文档模板是否已经有创建的文档,如果是,则激活文档所在框架
2如果否,则建立新文档/视图/框架
pDocument =pDocTemplate->CreateNewDocument();建立文档
CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(pDocument, NULL);建立框架
pDocTemplate->InitialUpdateFrame(pFrame ,pDocument,TRUE);初始化框架