User32GetParent(SafeHandle) Method

Retrieves a handle to the specified window's parent or owner.

To retrieve a handle to a specified ancestor, use the GetAncestor(IntPtr, GetAncestorFlags) 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", ExactSpelling = true, SetLastError = true)]
public static IntPtr GetParent(
	SafeHandle hWnd
)

Parameters

hWnd  SafeHandle
A handle to the window whose parent window handle is to be retrieved.

Return Value

IntPtr
If the window is a child window, the return value is a handle to the parent window.

If the window is a top-level window with the Popup style, the return value is a handle to the owner window.

If the function fails, the return value is Zero.

To get extended error information, call GetLastWin32Error.

Remarks

See Also