xMRi
xMRi

Reputation: 15375

Destroying a sibling window in WM_DESTROY handler yields to strange behaviour

I have a native Windows program that uses the Windows SDK. The program uses several child windows in a frame. When the frame is destroyed with DestroyWindow, WM_DESTROY messages are sent to the child windows.

I now have two windows that work as a pair of functions. When the first windows is created the corresponding sibling is created too.

When the first window is destroyed, the second window should also be destroyed. Both windows are siblings and have the frame window as their parent.

Is it allowed to destroy another sibling in the WM_DESTROY handler of a child window?

I have noticed that subsequent siblings then no longer receive WM_DESTROY messages at all when I delete a sibling in the handling of WM_DESTROY for the first part of the control. It seams that the list of controls to be destroyed is determined at the start of the parent frame destruction. When one of the windows is than later missing, sending WM_DESTROY is aborted at all.

PS: Yes I know, that I can combine them together to have again a single parent, that holds this control. So my question is more about if it is forbidden to modify the child windows of a frame in its destruction phase?

Upvotes: 1

Views: 70

Answers (0)

Related Questions