My delphi(7 or XE5) application is getting wrong monitor resolution when resolution is over 1920x1080.
I have a samsung ultra book with resolution of 2560x1440 running windows 8.1
When I run the simple resolution test, the app returns right at 1920x1080 and less, but when run the app with max resolution of 2560x1440 the resolution returned is 1600x900.
This is the code, I try with dpiaware manifest and get same wrong result, any idea about this ?
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetDesktopArea: TRect;
var
m: integer;
USCR: TScreen;
begin
USCR := TScreen.Create(Application);
try
with USCR do
if MonitorCount = 1 then
Result := WorkAreaRect
else
begin
for m:=0 to MonitorCount-1 do
begin
with Monitors[m] do
if Primary then
Result := Rect(Left, Top, Left+Width, Top+Height);
// UpdScreen.Monitors[m].BoundsRect;
end;
end;
finally
USCR.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
msg : String;
scr : TRect;
begin
scr := GetDesktopArea;
msg := Format('Left:%d Top:%d -- W:%d H:%d', [scr.Left, scr.Top, scr.Width, scr.Height] );
Memo1.Lines.Add( msg );
end;
end.
Thanks