I have some problems with getting screen resolution in Delphi 7 when scale is more that 125%.
Code I used for testing:
procedure TForm1.Button1Click(Sender: TObject);
var
MonId: integer;
Mon: TMonitor;
AllMonitorsWidth, AllMonitorsHeight: integer;
begin
Memo1.Clear;
Memo1.Lines.Append(Format('Number of monitors: %d', [Screen.MonitorCount]));
for MonId := 0 to Screen.MonitorCount - 1 do
begin
Mon := Screen.Monitors[MonId];
With Memo1.Lines do
begin
Append('');
Append(Format('-------- Monitor #%d --------', [mon.MonitorNum]));
Append(Format('Resolution: %dpx x %dpx', [Mon.Width, Mon.Height]));
Append(Format('X-offset: %dpx', [Mon.Left]));
Append(Format('Y-offset: %dpx', [Mon.Top]));
end;
end;
AllMonitorsWidth := GetSystemMetrics(SM_CXVIRTUALSCREEN);
AllMonitorsHeight := GetSystemMetrics(SM_CYVIRTUALSCREEN);
With Memo1.Lines do
begin
Append('');
Append('-------- All monitors --------');
Append(Format('Resolution: %dpx x %dpx', [AllMonitorsWidth, AllMonitorsHeight]));
Append(Format('PPI: %d', [Screen.PixelsPerInch]));
end;
end;
For example, I run this test on notebook with 1366x768 display and Windows 7. Results:
As you can see on 150% and 200% scale program detects wrong DPI=96 and resolution also incorect.
I think in modern versions of Delphi there are may be fixed. But is there any solution for Delphi 7 without upgrade to newer version?
Moreover there may be more than one display and with different DPIs. So I need to correct get resolution for each of them.



