User32DestroyWindow(IntPtr) Method

Destroys the specified window. The function sends WM_Destroy and WM_NcDestroy messages to the window to deactivate it and remove the keyboard focus from it.

The function also destroys the window's menu, flushes the thread message queue, 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(IntPtr) 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(IntPtr) also destroys modeless dialog boxes created by the CreateDialog function.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("User32.dll", CallingConvention = CallingConvention.StdCall, 
	SetLastError = true)]
public static IntPtr DestroyWindow(
	IntPtr hWnd
)

Parameters

hWnd  IntPtr
A handle to the window to be destroyed.

Return Value

IntPtr
If the function succeeds, the return value is Zero.

If the function fails, the return value is equal to a handle to the local memory object.

To get extended error information, call GetLastWin32Error.

Remarks

See Also