最近遇到这样一个问题:将一个窗口句柄以参数的形式传递给一个线程,在线程中使用完之后要将窗口销毁,调用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
时间: 2024-12-27 23:15:32