Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在VC+中销毁MDI子窗口+;6._C++ - Fatal编程技术网

C++ 在VC+中销毁MDI子窗口+;6.

C++ 在VC+中销毁MDI子窗口+;6.,c++,C++,我有一个子窗口,在CMainFrame中声明: CMDIChildWnd pMyMDI = new CMDIChildWnd; pMyMDI->Create(NULL, ..., ..., ..., this); .... some codes.... if (pMyMDI != NULL) { pMyMDI->DestroyWindow(); pMyMDI = NULL } 当我试图用“无效句柄”之类的消息破坏窗口时,它总是出错。如何获得句柄并安全地销毁此窗口?我

我有一个子窗口,在CMainFrame中声明:

CMDIChildWnd pMyMDI = new CMDIChildWnd;
pMyMDI->Create(NULL, ..., ..., ..., this);

.... some codes....

if (pMyMDI != NULL)
{
   pMyMDI->DestroyWindow();
   pMyMDI = NULL
}

当我试图用“无效句柄”之类的消息破坏窗口时,它总是出错。如何获得句柄并安全地销毁此窗口?

我相信您可以准确地转录错误消息。确切地说,“MyApp.exe中未处理的异常:0xC0000005:访问冲突”。它出现在代码第一次执行时。在“DestroyWindows()”行,很可能窗口已被销毁。我们不知道,因为我们看不见
。。。。。有些代码…
但是。。。pMyMDI!=是否检查空值?在运行“DestroyWindow()”之前是否有其他方法进行检查?这是意料之中的。当窗口关闭时,框架将删除对象,但不会将引用设置为
NULL