I am using Delphi XE5. I think i have a problem with my laptop. After a while, it returns wrong value to Screen.Width and GetSystemMetrics(SM_CXSCREEN) (same for Height). My OS is Windows 7 64-bit.
My laptop's screen res is 1920x1080 (1080p) however my app says it is 1280x720 (720p). I don't think there is a DPI problem as the problem goes when i reboot and starts after a while. Also Compatibality settings are off. Did anyone have this problem before? Or do you know a solution? I have also added the manifest below but didn't help
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings
xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
here is how i compiled it
1 24 "mf.txt"
EDIT:
Ok I wrote this function which is tricky way to fix it. I prefer Screen.Width return correct value:
function ScreenSize(var x, y: integer): boolean;
const
ENUM_CURRENT_SETTINGS = -1;
ENUM_REGISTRY_SETTINGS = -2;
var
dm: TDevMode;
begin
Result := False;
x := 0;
y := 0;
ZeroMemory(@dm, sizeof(dm));
if EnumDisplaySettings(nil, Cardinal(ENUM_CURRENT_SETTINGS), dm) then
begin
Result := True;
x := dm.dmPelsWidth;
y := dm.dmPelsHeight;
end else
begin
x := GetSystemMetrics(SM_CXSCREEN);
y := GetSystemMetrics(SM_CYSCREEN);
end;
end;
EDIT 2:
I have found SetProcessDPIAware
solved my problem but it doesn't work in XP