Get screen's physical ppi with Delphi 10.4 in windows 10

102 Views Asked by At

I am developing an application that draws on screen. I want to know the physical ppi of the screen to draw eg. a rectangle 2x2 inches to its actual size, so the user be able to measure it on screen as 2x2 inches.

1

There are 1 best solutions below

0
Shaun Roselt On

I've been using this function to get PPI of the primary screen on FireMonkey:

uses FMX.Platform

...

function GetScreenPPI: Double;
var
  ScreenService: IFMXScreenService;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, ScreenService) then
    Result := ScreenService.GetScreenScale() * 96
  else
    Result := 96; // Fallback to default of 96
end;