$include "windowssdk.inc" 'Note: HORZSIZE, VERTSIZE may be not accurate hDC=GetDC(NULL) INT Hpixels=GetDeviceCaps(hDC,HORZRES) 'display width in pixels INT Vpixels=GetDeviceCaps(hDC,VERTRES) 'display height in pixels INT Hmillimeters=GetDeviceCaps(hDC,HORZSIZE) 'display width in mm INT Vmillimeters=GetDeviceCaps(hDC,VERTSIZE) 'display height in mm Hmillimeters=25.4*Hpixels/GetDeviceCaps(hDC,LOGPIXELSX) Vmillimeters=25.4*Vpixels/GetDeviceCaps(hDC,LOGPIXELSY) ' When unadjusted, horz pixels are 339 and vert pixels are 271 ' This adjustment is needed on my monitor to get the correct window size of 80 * 40 Hmillimeters = 374 ' fix HORZSIZE (plus 35) Vmillimeters = 306 ' fix VERTSIZE (plus 35) ReleaseDC(NULL,hDC) DOUBLE PixelsPerMillimeter_H=Hpixels/(Hmillimeters+0.0) DOUBLE PixelsPerMillimeter_V=Vpixels/(Vmillimeters+0.0) DOUBLE MillimetersPerPixel_H=Hmillimeters/(Hpixels+0.0) DOUBLE MillimetersPerPixel_V=Vmillimeters/(Vpixels+0.0) MESSAGEBOX 0,USING("This monitor has # pixels (# millimeters) horizontally\nand # pixels (# millimeters) vertically.\n\nIn other words, one pixel is #.##mm * #.##mm",_ Hpixels,Hmillimeters,_ Vpixels,Vmillimeters,_ MillimetersPerPixel_H,MillimetersPerPixel_V),"Screen Size",MB_TOPMOST WINDOW win OPENWINDOW win,0,0,0,0,@MINBOX|@MAXBOX,0,"Metrics test",&main WINRECT rc ' Number of pixels = PixelsPerMillimeter * number of millimeters ' Set your own window dimensions - this example is 80 x 40 rc.right=PixelsPerMillimeter_H*80 rc.bottom=PixelsPerMillimeter_V*40 AdjustWindowRectEx(&rc,GetWindowLong(win.hWnd,GWL_STYLE),0,GetWindowLong(win.hWnd,GWL_EXSTYLE)) SetWindowPos(win.hWnd,HWND_TOPMOST,0,0,rc.right,rc.bottom,SWP_NOMOVE) CENTERWINDOW win PRINT win,"This window should be 80 * 40 mm" MOVE win,0,24 PRINT win,STR$(rc.right)+" wide" MOVE win,0,48 PRINT win,STR$(rc.bottom)+" deep" WAITUNTIL IsWindowClosed(win) END SUB main(),INT SELECT @MESSAGE CASE @IDCLOSEWINDOW CLOSEWINDOW *@HITWINDOW ENDSELECT RETURN 0 ENDSUB