码迷,mamicode.com
首页 > Windows程序 > 详细

DestroyWindow函数注意事项

时间:2015-04-07 23:10:52      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:

最近遇到这样一个问题:将一个窗口句柄以参数的形式传递给一个线程,在线程中使用完之后要将窗口销毁,调用DestroyWindow销毁窗口是返回false,GetLastError的结果为5:拒绝访问,而在线程外则是可以销毁的。

查阅msdn,解释如下:

A thread cannot use DestroyWindow to destroy a window created by a different thread.

 

此外,还有以下需要注意的点:

If the specified window is a parent or owner window, DestroyWindow automatically destroys the associated child or owned windows when it destroys the parent or owner window. The function first destroys child or owned windows, and then it destroys the parent or owner window.

 

If the window being destroyed is a child window that does not have the WS_EX_NOPARENTNOTIFY style, a WM_PARENTNOTIFY message is sent to the parent.

 

更多信息详见msdn:https://msdn.microsoft.com/en-us/library/ms632682.aspx

 

DestroyWindow函数注意事项

标签:

原文地址:http://www.cnblogs.com/mhscn/p/4399893.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!