An application can determine the parent, child, and owner windows for any window by using the WinQueryWindow function. This function returns the window handle of the requested window.
The code fragment in the following figure determines the parent window of the given window:
HWND hwndParent; HWND hwndMyWindow; hwndParent = WinQueryWindow(hwndMyWindow, QW_PARENT);
The code fragment in the following figure determines the topmost child window (the child window in the top z-order position):
HWND hwndTopChild; HWND hwndParent; hwndTopChild = WinQueryWindow(hwndParent, QW_TOP);
If a given window does not have an owner or child window, WinQueryWindow returns NULL.