为什么有的窗口类会不调用OnDestroy

scxy 2004-10-26 10:33:23
窗口是从CDialog继承的,有的子类可以,有的不可以
...全文
239 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
scxy 2004-12-01
  • 打赏
  • 举报
回复
这些窗口是我自己通过Create,创建的,最后手动调用一下DestroyWindow就可以了
likunfeng 2004-11-04
  • 打赏
  • 举报
回复
BOOL CDlgDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
TRACE(_T("DestroyWindow\n"));
return CDialog::DestroyWindow();
}
void CDlgDlg::OnDestroy()
{
CDialog::OnDestroy();
TRACE(_T("OnDestroy\n"));
// TODO: Add your message handler code here
}

以上两个先后执行
具体请看 侯杰 深入浅出 MFC 第二版 29 页 Windows 程序的生与死
scxy 2004-11-03
  • 打赏
  • 举报
回复
再看看是否有人回答
scxy 2004-11-01
  • 打赏
  • 举报
回复
WM_NCDESTROY会响应,但WM_DESTROY就是不响应,我也觉得奇怪
huwei001982 2004-10-29
  • 打赏
  • 举报
回复
对话框的 OnCancel , OnOk 这两个函数是比较特殊的

执行它们后, 根本就不响应 WM_CLOSE

但 WM_DESTORY 还是会响应的
superhandsome 2004-10-29
  • 打赏
  • 举报
回复
你在ONDESTORY里面写一句MessageBox("I LOVE U");
看它到底执行了没。。。
The framework calls this member function to inform the CWnd object that it is being destroyed. OnDestroy is called after the CWnd object is removed from the screen.

OnDestroy is called first for the CWnd being destroyed, then for the child windows of CWnd as they are destroyed. It can be assumed that all child windows still exist while OnDestroy runs.

If the CWnd object being destroyed is part of the Clipboard-viewer chain (set by calling the SetClipboardViewer member function), the CWnd must remove itself from the Clipboard-viewer chain by calling the ChangeClipboardChain member function before returning from the OnDestroy function.

scxy 2004-10-29
  • 打赏
  • 举报
回复
因为这个就是一个CDialog的子类,代码比较杂,也没有贴代码,所以问问大家是否遇到过这种问题
Mr-Chen 2004-10-27
  • 打赏
  • 举报
回复
楼主看一下这个帖子

http://community.csdn.net/Expert/topic/3452/3452436.xml?temp=.3294184
anothervip 2004-10-27
  • 打赏
  • 举报
回复
用OnOk(),OnCancel()。
社会栋梁 2004-10-27
  • 打赏
  • 举报
回复
不可能啊,想见识一下,哪个?
kugou123 2004-10-26
  • 打赏
  • 举报
回复
能不能贴点代码看看?楼主。
薛定谔之死猫 2004-10-26
  • 打赏
  • 举报
回复
不会吧
scxy 2004-10-26
  • 打赏
  • 举报
回复
请大家解答一下

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧