windows_programming_notes.nbk: Home | Index | Next Page: GetROP2 | Previous Page: GetOpenFileName
The GetParent function 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( HWND hWnd );
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, the return value is a handle to the owner window. If the window is a top-level unowned window or if the function fails, the return value is NULL. To get extended error information, call GetLastError. For example, this would determine, when the function returns NULL, if the function failed or the window was a top-level window.
Note that, despite its name, this function can return an owner window instead of a parent window. To obtain the parent window and not the owner, use [GetAncestor] with the GA_PARENT flag.
For an example, see Initializing a Dialog Box.
windows_programming_notes.nbk: Home | Index | Next Page: GetROP2 | Previous Page: GetOpenFileName
Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time