Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to convert pixels to inches/cm?
Message
De
22/08/2006 07:32:43
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
21/08/2006 20:04:22
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01147454
Message ID:
01147513
Vues:
13
This message has been marked as the solution to the initial question of the thread.
>Hi,
>
>I have a grid on a form. I'd like to be able to generate a report based on the information shown in the columns while preserving the grid column order and widths. I've created reports on the fly at runtime that work except for the fact that I cannot reliably determine what the column widths are (in inches) for the report.
>
>Does anyone know how I can convert the grid's column width from pixels to inches?
>
>TIA
>
>Mike

Here is a sample:
Declare Integer ReleaseDC In Win32Api;
  INTEGER nwnd, Integer hdc
Declare Integer GetDeviceCaps In Win32API;
  INTEGER hdc, Integer nIndex
Declare Integer GetWindowDC In Win32API;
  INTEGER HWnd

#Define WU_LOGPIXELSX  88
lnDC = GetWindowDC(0)
lnPixelsPerInch = GetDeviceCaps(lnDC, WU_LOGPIXELSX)
lnDC = ReleaseDC(0, lnDC)

lcFont = 'Arial' && _Screen.FontName
lnFontSize = _Screen.FontSize
lcStyle = ;
  Iif(_Screen.FontBold,'B','')+;
  Iif(_Screen.FontItalic,'I','')+;
  Iif(_Screen.FontUnderline,'U','')
lcStyle = Iif( Empty(m.lcStyle),'N',m.lcStyle)
lcTextToMeasure = "Sample text"
lnSizeInPixels = Txtwidth(m.lcTextToMeasure, m.lcFont, m.lnFontSize,m.lcStyle) * ;
  fontmetric(6, m.lcFont, m.lnFontSize,m.lcStyle)
lnSizeInTwips = ( m.lnSizeInPixels  / m.lnPixelsPerInch * 1440 )
lnSizeInPoints = m.lnSizeInTwips / 20
lnSizeInInches = m.lnSizeInTwips / 1440
lnSizeInCm = m.lnSizeInTwips / 1440 * 2.54
clear
TEXT TO m.lcDisplay TEXTMERGE noshow
Pixels per inch is: <<m.lnPixelsPerInch>>
Font: <<m.lcFont>>, <<m.lnFontSize>>, <<m.lcStyle>>
String "<<m.lcTextToMeasure>>" measures:
In pixels:	<<m.lnSizeInPixels>>
In Twips:	<<m.lnSizeInTwips>>
In points:	<<m.lnSizeInPoints>>
In Inches:	<<m.lnSizeInInches>>
In centimeters:	<<m.lnSizeInCm>>
endtext
? m.lcDisplay
* 1 Twip = 1/20 point, 567 twips 1 cm ~ 1440/2.54, 1 inch = 72pts = 1440 twips
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform