WinQueryWindowRect
Appearance
This function returns a window rectangle.
Syntax
WinQueryWindowRect(hwnd, prclDest);
Parameters
- hwnd (HWND) - input
- Window handle whose rectangle is retrieved.
- prclDest (PRECTL) - output
- Window rectangle.
- Window rectangle of hwnd, in window coordinates.
- Note: The value of each field in this structure must be in the range -32,768 through 32,767. The data type WRECT may also be used, if supported by the language.
Returns
- rc (BOOL) - returns
- Rectangle-returned indicator.
- TRUE: Rectangle successfully returned.
- FALSE: Rectangle not successfully returned.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
Remarks
The rectangle is in window coordinates relative to itself, so that the bottom left corner is at the position (0,0).
If the size of a frame window has been changed to zero by WinSetWindowPos or WinSetMultWindowPos, the original size is returned because the window is hidden, not sized, in this instance.
Example Code
Declaration:
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, Also in COMMON section */ #include <os2.h> HWND hwnd; /* Window handle whose rectangle is retrieved. */ PRECTL prclDest; /* Window rectangle. */ BOOL rc; /* Rectangle-returned indicator. */ rc = WinQueryWindowRect(hwnd, prclDest);
This example gets the dimensions of the window and calls WinInvalidateRect to invalidate the window. The application will be sent a WM_PAINT message with the entire window as the update rectangle.
#define INCL_WINWINDOWMGR #include <os2.h> HAB hab; HWND hwnd; RECTL rcl; WinQueryWindowRect(hwnd, &rcl); WinInvalidateRect(hwnd, /* window to invalidate */ &rcl, /* invalid rectangle */ FALSE); /* do not include children */