************************************************************************************************ * Function to Convert from Pixels to Twips * * Parameters: * pnPixels Value to convert to twips * pcDirection Screen direction; 'H' for horizontal and 'V' for vertical * * Returns: * Twips value * FUNCTION PixelsToTwips LPARAMETERS pnPixels, pcDirection LOCAL lhDeviceHdl, lnPixelsPerInch #DEFINE LOGPIXELSX 88 #DEFINE LOGPIXELSY 90 DECLARE LONG GetDeviceCaps IN "gdi32" LONG hdc, LONG nIndex DECLARE LONG ReleaseDC IN "user32" LONG hwnd, LONG hdc DECLARE LONG GetDC IN "user32" LONG hwnd lhDeviceHdl = GetDC(0) DO CASE CASE pcDirection = "H" && Horizontal lnPixelsPerInch = GetDeviceCaps(lhDeviceHdl,LOGPIXELSX) CASE pcDirection = "V" && Vertical lnPixelsPerInch = GetDeviceCaps(lhDeviceHdl,LOGPIXELSY) ENDCASE lhDeviceHdl = ReleaseDC(0,lhDeviceHdl) RETURN pnPixels * 1440 / lnPixelsPerInch ENDFUNCIn the above code on the RETURN statement, do not multiply by 1440 to get inches returned. You have to be sensitive to the vertical and horizontal directions as these can provide different values.