DestroyWindow not destroying owned windows

DestroyWindow not destroying owned windows

Post by news » Tue, 30 May 2006 23:51:47


According to the docs "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" but that's
not what I find.

If I create a modeless dialog box, owned by my window but with its own
message loop running in a different thread, DestroyWindow destroys my
window but *not* the dialog box. That only gets destroyed when my
application quits. I've confirmed that the dialog box really is owned
by my window using GetWindowLong(hdlg, GWL_HWNDPARENT).

Is this an error in the documentation or can I be doing something wrong
to cause it? The structure of my application is such that I have to
run the dialog box's message loop in a separate thread.

Richard.
http://www.yqcomputer.com/
To reply by email change 'news' to my forename.
 
 
 

DestroyWindow not destroying owned windows

Post by William De » Wed, 31 May 2006 04:47:31

< XXXX@XXXXX.COM > wrote in


I think it is a doc bug. Note that further down in the remarks section there
is this:

<quote>
A thread cannot use DestroyWindow to destroy a window created by a different
thread.
</quote>

So, I think that the part you quote is describing the usual state of affairs
where parent, owner and child are all associated with the same thread. IME,
splitting UI chores across threads is fraught with gotchas.

--
Regards,
Will

"I'm not ready to make nice, I'm not ready to back down ..."

 
 
 

DestroyWindow not destroying owned windows

Post by news » Wed, 31 May 2006 16:57:34


Thanks, I guess that explains it.


I certainly agree that splitting the UI chores of a single window
between threads is problematic (I do that too!) but I've not noticed
any gotchas when running different (top level) windows, such as
modeless dialog boxes, in different threads.

Richard.
http://www.yqcomputer.com/
To reply by email change 'news' to my forename.