GetParent function (winuser.h)
Retrieves a handle to the specified window's parent or owner.
To retrieve a handle to a specified ancestor, use the GetAncestor function.
HWND GetParent( [in] HWND hWnd );
A handle to the window whose parent window handle is to be retrieved.
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 WS_POPUP style, the return value is a handle to the owner window.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
This function typically fails for one of the following reasons:
- The window is a top-level window that is unowned or does not have the WS_POPUP style.
- The owner window has WS_POPUP style.
To obtain a window's owner window, instead of using GetParent, use GetWindow with the GW_OWNER flag. To obtain the parent window and not the owner, instead of using GetParent, use GetAncestor with the GA_PARENT flag.
For an example, see Initializing a Dialog Box.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|Header||winuser.h (include Windows.h)|
|API set||ext-ms-win-ntuser-window-l1-1-0 (introduced in Windows 8)|