当我关闭可停靠窗口时未调用OnClose()事件 [英] OnClose() Event not called when i close my Dockable Window

查看:156
本文介绍了当我关闭可停靠窗口时未调用OnClose()事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MFC中创建了一个项目,在其中选择了Visual Studio样式应用程序.

在其中,我删除了现有的可停靠窗口.

我创建了自己的可停靠窗口,名称为"CMyDockWindow"

当我运行该项目时,它的工作正常,显示一个停靠窗口..

我在该"CMyDockWindow"类中添加了 OnClose()事件.

但是当我在应用程序中关闭停靠窗口时,该事件没有触发.

我已经使用向导添加了 OnClose()例程,并且该例程未显示任何错误.

当我关闭我的Dock窗口时是否命中ON_WM_CLOSE()?

I created a project in MFC, in which i choose Visual Studio Style Application.

In it i deleted the existing dockable windows.

I created my own dockable window under name "CMyDockWindow"

When i run the project its working fine, showing a dock window..

i added an OnClose() event in that "CMyDockWindow" class.

but when i close my dock window in my app, the event doesnt fired.

i have added that OnClose() routine using wizard, and its not showing any errors.

Is it ON_WM_CLOSE() hit when i close my Dock Window?

推荐答案

WM_CLOSE并不总是在窗口上调用. Windows文档指出:

WM_CLOSE消息是作为窗口或应用程序应终止的信号发送的.

通常,当用户留下一些未保存的更改时,您会捕获WM_CLOSE来实现用户提示.然后,要真正关闭该窗口,可以调用DestroyWindow,它依次生成WM_DESTROY和WM_NCDESTROY消息.

更好地捕获WM_NCDESTROY,这是窗口看到的最后一条消息.这是进行清理的好方法.
WM_CLOSE is not always called on a window. The windows documentation states:

The WM_CLOSE message is sent as a signal that a window or an application should terminate.

Normally you catch WM_CLOSE to implement a user prompt, when the user has left some unsaved changes. Then, to really close the window you would call DestroyWindow, which in turn generates a WM_DESTROY and a WM_NCDESTROY message.

Better catch WM_NCDESTROY, which is the last message that a window ever sees. That''s a good point to do cleanup.


这篇关于当我关闭可停靠窗口时未调用OnClose()事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆