BOOL DestroyWindow(hwnd) | |||||
HWND hwnd; | /* handle of window to destroy | */ |
The DestroyWindow function destroys the specified window. The function sends appropriate messages to the window to deactivate it and remove the input focus. It also destroys the window's 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, DestroyWindow automatically destroys these child windows when it destroys the parent window. The function destroys child windows first, and then the window itself.
The DestroyWindow function also destroys modeless dialog boxes created by the CreateDialog function.
hwnd
Identifies the window to be destroyed.
The return value is nonzero if the function is successful. Otherwise, it is zero.
If the window being destroyed is a child window and does not have the WS_NOPARENTNOTIFY style set, a WM_PARENTNOTIFY message is sent to the parent.
The following example responds to the application-defined menu command IDM_EXIT, and then calls DestroyWindow to destroy the window:
case IDM_EXIT:
DestroyWindow(hwnd);
return 0;