WinQueryWindow
Appearance
This function returns the handle of a window that has a specified relationship to a specified window.
Syntax
WinQueryWindow(hwnd, lCode)
Parameters
- hwnd (HWND) - Input
- Handle of window to query.
- lCode (LONG) - Input
- Type of window information to return.
- QW_NEXT
- Next window in z-order (window below).
- QW_PREV
- Previous window in z-order (window above).
- QW_TOP
- Topmost child window.
- QW_BOTTOM
- Bottommost child window.
- QW_OWNER
- Owner of window.
- QW_PARENT
- Parent of window.
- QW_NEXTTOP
- Returns the next window of the owner window hierarchy subject to their z-ordering. The enumeration order is: 1. Owned windows in z-order. 2. Next z-ordered window's owned windows. 3. Hierarchy of windows with the same owner, repeated up the owner tree. 4. Hierarchy of unowned windows.
- QW_PREVTOP
- Returns the previous main window in the QW_NEXTTOP enumeration order.
- QW_FRAMEOWNER
- Returns the normalized owner of hwnd (same parent if applicable).
- hwndRelated (HWND) - Returns
- Handle of the related window.
Returns
- hwndRelated (HWND) - returns
- Handle of window related to hwnd.
Remarks
When enumerating windows of other threads, it's not guaranteed all windows will be found due to potential z-order changes. WinGetNextWindow should be used for reliable enumeration.
When called with QW_OWNER or QW_PARENT and the desktop window is reached, the return value is WinQueryDesktopWindow(hab, NULLHANDLE), not HWND_DESKTOP.
When called with QW_PARENT for an object window, the return value is the handle of the object window associated with the desktop window, as returned by WinQueryObjectWindow.
Errors
Possible returns from WinGetLastError:
- PMERR_INVALID_HWND (0x1001) - An invalid window handle was specified.
- PMERR_PARAMETER_OUT_OF_RANGE (0x1003) - The value of lCode was not within the valid range.
Example Code
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwnd; /* Handle of window to query. */ LONG lCode; /* Type of window information. */ HWND hwndRelated; /* Window handle. */ hwndRelated = WinQueryWindow(hwnd, lCode);
This example shows how to get the frame window handle from the client window handle.
#define INCL_WINWINDOWMGR #define INCL_WINACCELERATORS #include <OS2.H> HACCEL haccel; HWND hwndFrame, hwndClient; /* window handles. */ HAB hab; /* anchor block. */ hwndFrame = WinQueryWindow(hwndClient, QW_PARENT); /* get handle of parent, */ /* which is frame window. */