DestroyWindow

  BOOL DestroyWindow(hwnd)    
  HWND hwnd; /* handle of window to destroy */

This function destroys the specified window. The DestroyWindow function hides or permanently closes the window, sending the appropriate messages to the window to deactivate it and remove the keyboard focus. It also destroys the window menu, flushes the application queue, destroys outstanding timers, removes clipboard ownership, and breaks the clipboard-viewer chain, if the window is at the top of the viewer chain. It sends WM_DESTROY and WM_NCDESTROY messages to the window.

If the given window is the parent of any windows, these child windows are automatically destroyed when the parent window is destroyed. DestroyWindow destroys child windows first, and then the window itself.

DestroyWindow also destroys modeless dialog boxes created by the CreateDialog function.

Parameters

hwnd

Identifies the window to be destroyed.

Return Value

The return value specifies whether or not the specified window is destroyed. It is nonzero if the window is destroyed. Otherwise, it is zero.

Comments

If a thread creates a window, only that thread is allowed to destroy it by calling DestroyWindow. Other threads in the process will not be permitted to do so. This can happen inside a window procedure or outside the message loop. This is not a general policy regarding threads and objects they create; currently it only applies to window objects.

See Also

CreateDialog, CreateWindow