delphi-xetform

Delphi screen dimensions differ on two apps on same machine...how to resolve?


I have two applications that use some of the same forms. I noticed that these forms were displaying differently when I ran the applications. I put this code at the top of the project source:

var f: TextFile;
s: String;

{$R *.res}

begin

s := TPath.GetFileNameWithoutExtension(Application.ExeName);
AssignFile(f, s + '-screen.txt');
Rewrite(f);
Writeln (f, s + '.Desktop TLHW: ' + IntToStr(screen.DesktopTop) + ', ' +
                                    IntToStr(screen.DesktopLeft) + ', ' +
                                    IntToStr(screen.DesktopHeight) + ', ' +
                                    IntToStr(screen.DesktopWidth));
CloseFile (f);

aDAM2-screen.txt showed: aDAM2.Desktop TLHW: 0, 0, 720, 1280

aDAM3-screen.txt showed: aDAM3.Desktop TLHW: 0, 0, 1080, 1920

I don't understand how this happens and am at a loss to resolve this, especially given that the TScreen properties are read-only.


Solution

  • The likely explanation is that one program is subject to DPI virtualization, the other is not. The system has 150% font scaling specified.

    The true resolution is 1920 by 1080, and aDAM3 is reporting that, because it is not subject to DPI virtualization.

    On the other hand aDAM2 is subject to DPI virtualization, and so reports virtualized dimensions, which are the true dimensions divided by 1.5. That is 1280 by 720.