Главная страница | назад





Article #17506: Implementing the VB TwipsPerPixel in Delphi

 Question and Answer Database
FAQ: FAQ2506D — Implementing the VB TwipsPerPixel in Delphi
Category: VCL
Platform: All Windows
Product:
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;
8/3/99 1:47:39 PM

Last Modified: 01-SEP-99