Destroying Windows

In general, an application must destroy all the windows it creates. Use the DestroyWindow function to destroy a window. When a window is destroyed, the system hides the window, sends a WM_DESTROY message to the window procedure of the window being destroyed, and removes any internal data associated with the window. The window handle becomes invalid and can no longer be used by the application.

Destroying a window automatically destroys the window's descendant windows. The DestroyWindow function sends a WM_DESTROY message to the initial window being destroyed and then to its descendant windows. Any windows owned by the window are also automatically destroyed.

You should destroy any window that is no longer needed. Before destroying a window, you should save or remove any data associated with the window and release any system resources allocated for the window. Windows CE releases any resources that you do not release.

Destroying a window does not affect the window class from which the window is created. You can still create new windows by using the class, and any existing windows of that class continue to operate.