type
TPixDistXY = Record
X: Double;
Y: Double;
end;
function Mesurer(const PixDistX, PixDistY:Integer) : TPixDistXY; // PixDistX est une mesure en pixels.
var DC : HDC;
begin
DC := GetWindowDc(0); // Obtenir contexte graphique de l'écran
Result.X := PixDistX * GetDeviceCaps(DC,HORZSIZE) / GetDeviceCaps(DC,HORZRES);
Result.Y := PixDistY * GetDeviceCaps(DC,VERTSIZE) / GetDeviceCaps(DC,VERTRES);
end;
{Exemple d'utilisation.}
procedure TForm1.Button1Click(Sender: TObject);
var aPixDistXY: TPixDistXY;
begin
aPixDistXY := Mesurer(Screen.Width, Screen.Height);
Edit1.Text := FormatFloat('####.##" mm."',aPixDistXY.X) + ' x '
+FormatFloat('####.##" mm."',aPixDistXY.Y);//Renverra, par ex : 410 mm. x 256 mm.
end;