Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function destroys the specified window. The function sends a WM_DESTROY message to the window to deactivate it and removes the keyboard focus from it. The function also destroys the window's menu, destroys timers, removes clipboard ownership, and breaks the clipboard viewer chain (if the window is at the top of the viewer chain).

If the specified window is a parent or owner window, DestroyWindowautomatically 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.

DestroyWindowalso destroys modeless dialog boxes created by the CreateDialogfunction.

Syntax

BOOL DestroyWindow( 
  HWND 
hWnd 
); 

Parameters

hWnd

[in] Handle to the window to be destroyed.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

The DestroyWindowfunction does not support the WM_PARENTNOTIFY message.

DestroyWindowdestroys children of the specified window.

DestroyWindowdoes not flush the thread message queue.

Do not use DestroyWindowin one thread to destroy a window created by a different thread.

Requirements

Header winuser.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also