解决方案 »
- VC2008中,如何把调试时显示变量变化的框(左下方的)显示出来
- 如何去掉toolbar上面的那个windows工具栏上的默认的横条??急!!!!
- 请教,如何使用“select count(*) from 表名 where 条件” 语句来得到数据表的记录数!
- 怎么把一个JPEG图像当作资源显示在对话框中?
- 请问哪有visual studio 6.0 中文企业版下载
- 怎样调试服务器端组件?UP,GZ有分。快速结贴!
- 使用GDI+能不能将BMP保存为JPEG(Exif)
- 安装程序时所添加注册的OCX怎样在卸载时不删除和反注册?
- 求助——关于如何将8位彩色位图转换成灰度图
- nsis 问题
- visual studio 2012 安装
- 请教关于IOCP服务器ERROR_CONNECTION_ABORTED的问题
谢谢您的帮助,我加入如下代码,没效果,还是一样出错,不知道哪里出了问题?请大家指教!void CSwhMdiMisFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
CMainFrame* crd=(CMainFrame*)GetParent();
crd->m_pFuncFrame=NULL;
delete crd->m_pFuncFrame;
CMDIChildWnd::OnClose();
}
{
delete m_pFuncFrame;
m_pFuncFrame=0;
}
m_pFuncFrame = new CSwhMdiMisFrame();
{
delete m_pFuncFrame;
m_pFuncFrame = 0;
}
m_pFuncFrame = new CSwhMdiMisFrame();
没有把指针置空掉。你应该析构的地方delete再置空指针
if(m_pFuncFrame)
{
delete m_pFuncFrame;
m_pFuncFrame = 0;
}
// 是防止多次 new
m_pFuncFrame = new CSwhMdiMisFrame();
//
最后析构的地方还要 delete
-----------------------------
CSwhMdiMisFrame的基类是什么?CFrameWnd吗?
void CSwhMdiMisFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
CMainFrame* crd=(CMainFrame*)GetParent();
delete crd->m_pFuncFrame;//顺序反一下
crd->m_pFuncFrame=NULL;
CMDIChildWnd::OnClose();
}
基类是CMDIChildWnd
我看了您的代码,这是可以的,不管childframe有没有打开我都重建,但是违背了我的初衷:
如果这个childframe 已经打开了,我就直接激活,不要重建,如果没打开在重建
if (m_pFuncFrame != NULL)
{
m_pFuncFrame->MDIActivate();
return ;
}
m_pFuncFrame = new CSwhMdiMisFrame();
m_pFuncFrame初始化为NULL。m_pFuncFrame = NULL;
如果有地方析构的话,那么delete m_pFuncFrame之后,不要忘记m_pFuncFrame = NULL;
m_pFuncFrame = NULL;
}----------------------------
// SwhMdiMisFrame.cpp : implementation file#include "MainFrm.h"CSwhMdiMisFrame::~CSwhMdiMisFrame(){
CMainFrame* crd=(CMainFrame*)GetParent();//关闭时,运行到这里出错了提示: file:afxwin2.inl line 265delete crd->m_pFuncFrame;//crd->m_pFuncFrame=NULL;
}
不知道是哪里出了问题,请指教!谢谢先
{
delete m_pFuncFrame;
m_pFuncFrame = NULL;
}
“运行后有frame出来,当关闭有再次打开时运行到这里 m_pFuncFrame->MDIActivate(); 出错”可能是MDIActivate()函数的代码有问题
void CFuncView::OnDestroy()
{
CFormView::OnDestroy();
// TODO: Add your message handler code here
((CMainFrame*)AfxGetMainWnd())->m_pFuncFrame=NULL;
}