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, DestroyWindow automatically 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.

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

BOOL DestroyWindow( 
HWND hWnd ); 


  • hWnd
    Handle to the window to be destroyed.

Return Values

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


The DestroyWindow function does not support the WM_NCDESTROY or the WM_PARENTNOTIFY message.

DestroyWindow destroys children of the specified window.

DestroyWindow does not flush the thread message queue.


Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winuser.h    

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CreateDialog, CreateWindow, CreateWindowEx, WM_DESTROY

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.