What is the difference between WM_DESTROY and WM_NCDESTROY?
来源:互联网 发布:广联达是什么软件 编辑:程序博客网 时间:2024/05/16 09:30
There are two window messages closely-associated with window destruction, the WM_DESTROY
message and the WM_NCDESTROY
message. What's the difference?
The difference is that the WM_DESTROY
message is sent at the start of the window destruction sequence, whereas the WM_NCDESTROY
message is sent at the end. This is an important distinction when you have child windows. If you have a parent window with a child window, then the message traffic (in the absence of weirdness) will go like this:
hwnd = parent, uMsg = WM_DESTROYhwnd = child, uMsg = WM_DESTROYhwnd = child, uMsg = WM_NCDESTROYhwnd = parent, uMsg = WM_NCDESTROY
Notice that the parent receives the WM_DESTROY
before the child windows are destroyed, and it receives the WM_NCDESTROY
message after they have been destroyed.
Having two destruction messages, one sent top-down and the other bottom-up, means that you can perform clean-up appropriate to a particular model when handling the corresponding message. If there is something that must be cleaned up top-down, then you can use the WM_DESTROY
message, for example.
The WM_NCDESTROY
is the last message your window will receive (in the absence of weirdness), and it is therefore the best place to do "final cleanup". This is why our new scratch program waits until WM_NCDESTROY
to destroy its instance variables.
These two destruction messages are paired with the analogous WM_CREATE
and WM_NCCREATE
messages. Just as WM_NCDESTROY
is the last message your window receives, the WM_NCCREATE
message is the first message, so that's a good place to create your instance variables. Note also that if you cause the WM_NCCREATE
message to return failure, then all you will get is WM_NCDESTROY
; there will be no WM_DESTROY
since you never got the corresponding WM_CREATE
.
What's this "absence of weirdness" I keep alluding to? We'll look at that next time.
转自:http://blogs.msdn.com/b/oldnewthing/archive/2005/07/26/443384.aspx
- What is the difference between WM_DESTROY and WM_NCDESTROY?
- What is the difference between test, [ and [[ ?
- what is the difference between the setTimeout and setInterval
- What is the difference between DHTML and the DOM?
- What is the difference between the mouseover and mouseenter events?
- What is the difference between AWT and SWT?
- What is the difference between User Control and Custom Control?
- What is the difference between an EXE and a DLL?
- What is the difference between XML and C or C ?
- What is the difference between SMOD and CMOD?
- what is the difference between little-endian and big-endian.
- What is the difference between procedural and nonprocedural language?
- What is the difference between a thread and a process?
- What is the difference between objectForKey and valueForKey?
- What is the difference between Microsoft TMG and UAG ?
- What is the Difference Between http and https?
- what is the difference between ELF files and bin files
- what is the difference between MirrorView, SanCopy, SanpSure and SnapView
- NodeJs has no method 'router' 错误解决方法
- 策略模式
- 见微知著 从Select语句看Oracle查询原理
- Duff's Device
- abap中方法file_open_dialog的使用
- What is the difference between WM_DESTROY and WM_NCDESTROY?
- ServletContext对象读取资源路径的三种方式
- [STL] __gnu_cxx::hash_map使用中的一些问题
- Android FragmentPagerAdapter数据刷新notifyDataSetChanged没效果研究
- java 命令模式下运行jar包
- Mongodb认证设置
- 2012-2013百度搜索引擎优化大事记
- java项目公共接口GenericDao GenericDaoImpl
- Error opening terminal:xterm解决方法