當分辨率超過1920x1080時,我的delphi(7或XE5)應用程序出現錯誤的顯示器分辨率。德爾福在1920x1080獲得錯誤的顯示器分辨率,爲什麼?
我有一個三星的超簿與2560×1440運行的是Windows 8.1
當我運行簡單的分辨率測試的分辨率,應用程序返回,右爲1920x1080少,但是當運行與2560×1440分辨率最高分辨率的應用返回的是1600x900。
這是代碼,我嘗試使用dpiaware清單並得到相同的錯誤結果,對此有何想法?
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.
感謝
您的應用程序是否有明確聲明Windows 8.1支持的清單?您的應用程序是否支持高DPI?如果兩者都不是,那麼Windows將報告與其在幕後執行的縮放相關的虛擬化屏幕值。 「TScreen」只是報告Windows正在報告的內容。順便說一句,不要手動調用'TScreen.Create'。改爲使用「Vcl.Forms」單元中現有的全局「屏幕」對象。 –
看看http://stackoverflow.com/questions/26852150/how-can-i-make-windows-8-1-aware-that-my-delphi-application-wants-to-support-per –
FWIW ,我在Windows 8.1的2560x1440顯示器上每天運行XE7(當前),並且Delphi本身和我的應用程序都可以正常工作(至少在這方面)。而你的功能與雷米的修改(不創建一個自定義的TScreen實例)正確返回屏幕分辨率。 –