DestroyWindow

Syntax

BOOL DestroyWindow(hWnd)

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 input 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.

Parameter Type/Description  
hWnd 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.