- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


Frequently Asked Questions

Implementing the VB TwipsPerPixel in Delphi

Question:

I need the equivalent of the VB TwipsPerPixel functions. How can implement the same functionality in Delphi?

Answer:

The following example demonstrates two functions

   (TwipsPerPixelX, and TwipsPerPixelY) that implement

   the same functionality in Delphi.



Example:



function TwipsPerPixelX(Canvas : TCanvas) : Extended;

begin

  result := 1440 /

            GetDeviceCaps(Canvas.Handle,

            LOGPIXELSX);

end;



function TwipsPerPixelY(Canvas : TCanvas) : Extended;

begin

  result := 1440 /

            GetDeviceCaps(Canvas.Handle,

            LOGPIXELSY);

end;





procedure TForm1.Button1Click(Sender: TObject);

begin

  ShowMessage(FloatToStr(TwipsPerPixelX(Form1.Canvas)));

  ShowMessage(FloatToStr(TwipsPerPixelY(Form1.Canvas)));

end;



<End of FAQ>



* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile