WinDestroyWindow
This call destroys a window and its child windows.
Syntax
WinDestroyWindow(hwnd)
Parameters
- hwnd (HWND) - input
- Window handle.
Returns
- rc (BOOL) - returns
- Window-destroyed indicator.
- TRUE
- Window destroyed
- FALSE
- Window not destroyed.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
Remarks
The window to be destroyed must have been created by the thread that is issuing this call. Before hwnd is itself destroyed, all child windows of hwnd are also destroyed.
If hwnd cannot be destroyed, for example because hwnd is an invalid window handle or is not associated with the current thread, rc returns FALSE.
- Note
- If hwnd is locked, this call does not return until the window is unlocked (and destroyed).
Messages may be received from other processes or threads during the processing of this call.
If a Presentation Space is associated with the window, it is disassociated from it by this function. If the presentation space was obtained by use of GpiCreatePS then it is disassociated from the window, but not destroyed. That is, this function calls GpiAssociate to disassociate the presentation space but does not call GpiDestroyPS. If the presentation space was obtained by use of the WinGetPS function, it is released by this function; that is, this function performs the WinReleasePS function.
Messages sent by this call are:
- WM_DESTROY
- Always sent to the window being destroyed after the window has been hidden on the device, but before its child windows have been destroyed. The message is sent first to the window being destroyed, then to the child windows as they are destroyed. Therefore, during processing the WM_DESTROY it can be assumed that all the children still exist.
- WM_ACTIVATE
- Sent with if the window being destroyed is the active window.
- WM_RENDERALLFMTS
- Sent if the clipboard owner is being destroyed, and there are unrendered formats in the clipboard.
If the window being destroyed is the active window, both the active window and the input focus window are transferred to another window when the window is destroyed. The window that becomes the active window is the next window, as defined for the "Alt+Esc" function. This usually corresponds to the next application in the sequence. The input focus transfers to whichever window the new active window decides should have it.
If a menu window is being destroyed, any bit maps associated with the menu are not deleted. They will be deleted automatically when the application terminates.
Example Code
This example destroys the specified window and all other windows owned by that window in response to a WM_CLOSE message.
#define INCL_WINWINDOWMGR /* Window Manager functions */ #include <os2.h> ULONG fSuccess; HWND hwnd; /* Cursor display window */ case WM_CLOSE: fSuccess = WinDestroyWindow(hwnd);
Definition
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, Also in COMMON section */ #include <os2.h> HWND hwnd; /* Window handle. */ BOOL rc; /* Window-destroyed indicator. */ rc = WinDestroyWindow(hwnd);
Related Functions
- WinCalcFrameRect
- WinCreateFrameControls
- WinCreateStdWindow
- WinCreateWindow
- WinDefWindowProc
- WinQueryClassInfo
- WinQueryClassName
- WinRegisterClass
- WinSubclassWindow
Related Messages
- WM_ACTIVATE
- WM_DESTROY
- WM_RENDERALLFMTS