CFormview 关闭
时间:2011-12-17
来源:互联网
问题:
点击菜单 弹出新的视图:
void CMainFrame::OnClientinfo()
{
theApp.CreateView(VIEW_CLIENT,NULL); //theApp即CGkencliApp
}
void CGkencliApp::CreateView (int nViewType, LPVOID pData)
{
if (nViewType != VIEW_MAIN && nViewType != VIEW_EXPORT && nViewType != VIEW_CLIENT && pData == NULL)
return;
CGkencliView* pView = FindView(nViewType, pData);
if (pView)
{
ActiveView(pView->GetParent());
return;
}
pView = FindView (VIEW_MAIN, NULL);
double zoom = 1000;
if (pView)
zoom = pView->GetZoom ();
POSITION pos=GetFirstDocTemplatePosition();
CDocTemplate* temp;
if(pos)
temp=GetNextDocTemplate(pos);
CDocument* pDocument = temp->CreateNewDocument();
if (pDocument == NULL)
{
TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
return ;
}
ASSERT_VALID(pDocument);
CGkencliDoc* pDoc=(CGkencliDoc*)pDocument;
pDoc->SetParam(nViewType, pData, zoom);
BOOL bAutoDelete = pDocument->m_bAutoDelete;
pDocument->m_bAutoDelete = FALSE; // don't destroy if something goes wrong
CFrameWnd* pFrame = temp->CreateNewFrame(pDocument, NULL);
pDocument->m_bAutoDelete = bAutoDelete;
if (pFrame == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
delete pDocument; // explicit delete on error
return;
}
ASSERT_VALID(pFrame);
pFrame->ModifyStyle(WS_CAPTION | WS_BORDER, 0, 0);
//window title and position
pDocument->SetTitle(pDoc->m_strTitle);
if(nViewType == VIEW_MAIN)
pFrame->ModifyStyle(WS_SIZEBOX, 0, 0);
if (!pDocument->OnNewDocument())
{
// user has be alerted to what failed in OnNewDocument
TRACE0("CDocument::OnNewDocument returned FALSE.\n");
pFrame->DestroyWindow();
return ;
}
temp->InitialUpdateFrame(pFrame, pDocument);
LayoutWnd();
}
然后在:
void CGkencliView::OnInitialUpdate()
{
CEditMap::OnInitialUpdate();
CRect rect;
this->GetActiveWindow()->GetWindowRect(rect);
m_ClientControl.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rect,this,0,NULL);//创建视图对象m_ClientControl
m_ClientControl.ShowWindow(SW_SHOWNORMAL);
}
为什么退出系统时 出现以后错误::
Windows 已在 gkencli.exe 中触发一个断点。
其原因可能是堆被损坏,这说明 gkencli.exe 中或它所加载的任何 DLL 中有 Bug。
原因也可能是用户在 gkencli.exe 具有焦点时按下了 F12。
输出窗口可能提供了更多诊断信息。
如果不打开这个视图窗口则不会报错,第一次接触CformView 希望各位大侠指教!!
点击菜单 弹出新的视图:
void CMainFrame::OnClientinfo()
{
theApp.CreateView(VIEW_CLIENT,NULL); //theApp即CGkencliApp
}
void CGkencliApp::CreateView (int nViewType, LPVOID pData)
{
if (nViewType != VIEW_MAIN && nViewType != VIEW_EXPORT && nViewType != VIEW_CLIENT && pData == NULL)
return;
CGkencliView* pView = FindView(nViewType, pData);
if (pView)
{
ActiveView(pView->GetParent());
return;
}
pView = FindView (VIEW_MAIN, NULL);
double zoom = 1000;
if (pView)
zoom = pView->GetZoom ();
POSITION pos=GetFirstDocTemplatePosition();
CDocTemplate* temp;
if(pos)
temp=GetNextDocTemplate(pos);
CDocument* pDocument = temp->CreateNewDocument();
if (pDocument == NULL)
{
TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
return ;
}
ASSERT_VALID(pDocument);
CGkencliDoc* pDoc=(CGkencliDoc*)pDocument;
pDoc->SetParam(nViewType, pData, zoom);
BOOL bAutoDelete = pDocument->m_bAutoDelete;
pDocument->m_bAutoDelete = FALSE; // don't destroy if something goes wrong
CFrameWnd* pFrame = temp->CreateNewFrame(pDocument, NULL);
pDocument->m_bAutoDelete = bAutoDelete;
if (pFrame == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
delete pDocument; // explicit delete on error
return;
}
ASSERT_VALID(pFrame);
pFrame->ModifyStyle(WS_CAPTION | WS_BORDER, 0, 0);
//window title and position
pDocument->SetTitle(pDoc->m_strTitle);
if(nViewType == VIEW_MAIN)
pFrame->ModifyStyle(WS_SIZEBOX, 0, 0);
if (!pDocument->OnNewDocument())
{
// user has be alerted to what failed in OnNewDocument
TRACE0("CDocument::OnNewDocument returned FALSE.\n");
pFrame->DestroyWindow();
return ;
}
temp->InitialUpdateFrame(pFrame, pDocument);
LayoutWnd();
}
然后在:
void CGkencliView::OnInitialUpdate()
{
CEditMap::OnInitialUpdate();
CRect rect;
this->GetActiveWindow()->GetWindowRect(rect);
m_ClientControl.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rect,this,0,NULL);//创建视图对象m_ClientControl
m_ClientControl.ShowWindow(SW_SHOWNORMAL);
}
为什么退出系统时 出现以后错误::
Windows 已在 gkencli.exe 中触发一个断点。
其原因可能是堆被损坏,这说明 gkencli.exe 中或它所加载的任何 DLL 中有 Bug。
原因也可能是用户在 gkencli.exe 具有焦点时按下了 F12。
输出窗口可能提供了更多诊断信息。
如果不打开这个视图窗口则不会报错,第一次接触CformView 希望各位大侠指教!!
作者: angellove156 发布时间: 2011-12-17
....看到MFC 我就没勇气看下去
作者: zhifeiya 发布时间: 2011-12-17
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28