WinQueryWindowPos
Appearance
This function queries the window size and position of a visible window.
Syntax
WinQueryWindowPos(hwnd, pswp)
Parameters
- hwnd (HWND) - Input
- Window handle.
- pswp (PSWP) - Output
- SWP structure.
- The fields are set such that a call to WinSetWindowPos with those values sets the window to its current size and position, with the exception of the fl bits which are set as follows&colon.
- SWP_MOVE and SWP_SIZE are set to TRUE.
- SWP_ACTIVATE and SWP_DEACTIVATE are set to the current state of the window.
- If the window is minimized, SWP_MINIMIZE is set and SWP_MAXIMIZE is zero.
- If the window is maximized, SWP_MAXIMIZE is set and SWP_MINIMIZE is zero.
- If the window is neither minimized nor maximized, both SWP_MINIMIZE and SWP_MAXIMIZE are zero.
- All other bits are set to zero.
Returns
- rc (BOOL) - returns
- Success indicator.
- TRUE
- Successful completion
- FALSE
- Error occurred.
Errors
Possible returns from WinGetLastError:
- PMERR_INVALID_HWND (0x1001) An invalid window handle was specified.
- PMERR_INVALID_FLAG (0x1019) An invalid bit was set for a parameter. Use constants defined by PM for options, and do not set any reserved bits.
Example Code
#define INCL_WINWINDOWMGR #define INCL_WINSYS #include <OS2.H> HWND hwnd; /* window handle. */ SHORT ix, iy; SHORT iwidth, idepth; SWP swp; /* Query width and height of Screen device */ iwidth = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); idepth = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); /* Query width and height of dialog box */ WinQueryWindowPos( hwnd, &swp ); /* Center dialog box within the Screen */ ix = (SHORT)(( iwidth - swp.cx ) / 2); iy = (SHORT)(( idepth - swp.cy ) / 2); WinSetWindowPos( hwnd, HWND_TOP, ix, iy, 0, 0, SWP_MOVE );