* Form.PixelsToTwips custom method #Define cnLOG_PIXELS_X 88 #Define cnLOG_PIXELS_Y 90 #Define cnTWIPS_PER_INCH 1440 *-- Code for PixelToTwips method Local liHWnd, liHDC, liPixelsPerInchX, liPixelsPerInchY * Declare some Windows API functions. Declare Integer GetActiveWindow In WIN32API Declare Integer GetDC In WIN32API Integer iHDC Declare Integer GetDeviceCaps In WIN32API Integer iHDC, Integer iIndex * Get a device context for VFP. liHWnd = GetActiveWindow() liHDC = GetDC(liHWnd) * Get the pixels per inch. liPixelsPerInchX = GetDeviceCaps(liHDC, cnLOG_PIXELS_X) liPixelsPerInchY = GetDeviceCaps(liHDC, cnLOG_PIXELS_Y) * Get the twips per pixel. This.nxtwips = ( cnTWIPS_PER_INCH / liPixelsPerInchX ) This.nytwips = ( cnTWIPS_PER_INCH / liPixelsPerInchY )Code returning width in points.
Procedure GetPts Lparameters tcText, tnPixelsPerInch, tcFont, tnFontSize, tnStyle Local lcStyle lcStyle = Iif( Empty(tnStyle), 'N',; Iif(Bittest(tnStyle,0),'B','')+; Iif(Bittest(tnStyle,1),'I','')+; Iif(Bittest(tnStyle,2),'U','') ) lnSizeInPixels = ; Txtwidth(tcText, tcFont, tnFontSize,lcStyle) * Fontmetric(6, tcFont, tnFontSize,lcStyle) Return ( lnSizeInPixels / tnPixelsPerInch * 1440 ) / 20 * 1 Twip = 1/20 point, 567 twips 1 cm EndprocCetin