This example shows how to center a dialog box within the Screen using WinQueryWindowPos.
#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, (PSWP)&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 );