API to Calculate pixels per inch from twips

Chris Kelleher

Administrator
Staff member
<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
/* calculate pixels per inch */

/* 1 twip = 1/1440 inch */

{windows.i}

&GLOB LOGPIXELSX 88
&GLOB LOGPIXELSY 90

define variable hdc as integer no-undo.
define variable ReturnValue as integer no-undo.
DEFINE VARIABLE PixelsPerInchX as INTEGER NO-UNDO.
DEFINE VARIABLE PixelsPerInchY as INTEGER NO-UNDO.

run GetDC in hpApi (input default-window:hwnd, output hdc).
run GetDeviceCaps in hpApi (input hdc,input {&LOGPIXELSX}, output PixelsPerInchX).
run GetDeviceCaps in hpApi (input hdc,input {&LOGPIXELSY}, output PixelsPerInchY).
run ReleaseDC in hpApi (input default-window:hwnd, input hdc, output ReturnValue).

MESSAGE
'twips per pixel (horizontal) = ' (1440 / PixelsPerInchX)
SKIP
'twips per pixel (vertical) = ' (1440 / PixelsPerInchY)
VIEW-AS ALERT-BOX.


[/code]
 
Top