Question

Is it possible to have a valid HWND with a valid parent, and then the parent become invalid without the child becoming invalid?

Was it helpful?

Solution

No, see the documentation for DestroyWindow:

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.

OTHER TIPS

Only if you'd first call SetParent on the child window. DestroyWindow will destoy a window and all its current child windows.

Since windows have thread affinity, and children have the same thread affinity as their parents, there's no risk of a race condition between SetParent and DestroyWindow.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top