Screen.Monitors

delphi package - automated exception handling
Post Reply
Han312
Posts: 54
Joined: Mon Mar 14, 2016 3:49 pm

Screen.Monitors

Post by Han312 »

In RemoveCommandLineHeaderInfo I am trying to add additional data.

But for some reason the data which I get via screen.Monitors are wrong.
I have a 4k monitor with 150%. When I start my application
Screen.monitors[ 0 ].pixelsperinch = 144
Screen.monitors[ 0 ].width = 3840

After I create a crash the data I retrieve within of RemoveCommandLineHeaderInfo are different
Screen.monitors[ 0 ].pixelsperinch = 96
Screen.monitors[ 0 ].width = 2560

Is this a Delphi-bug? Any idea whether I can prevent it?
A workaround could be that I store the monitor data while the application is running.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Screen.Monitors

Post by madshi »

madExcept tells the OS that it should handle high DPI setting stuff automatically. This allows the madExcept windows to be scaled up properly to the right DPI size. However, this probably affects the "Screen" functionality.

You could store the monitor while the application is running. Or alternatively, you could create a small helper thread to fetch the information. That should work, as well. I'm not sure if "Screen" is thread safe, though.
Han312
Posts: 54
Joined: Mon Mar 14, 2016 3:49 pm

Re: Screen.Monitors

Post by Han312 »

It also looks so whether GetDisplayModeString is affected.

I store now the data and added some lines which work fine.
operating system : Windows 10 Tablet PC x64 build 18362
display mode : 1536x864, 32 bit
TM - monitors[0] : 1920x1080@125%, EW: 1536, T:0 L:0, Intel(R) UHD Graphics 620, (primary)
or
operating system : Windows 10 x64 build 18362
display mode : 1631x918, 32 bit
TM - monitors[0] : 1920x1080@118%, EW: 1631, T:0 L:0, Intel(R) HD Graphics 4600, (primary)
TM - monitors[1] : 1920x1080@118%, EW: 1631, T:0 L:1920, Intel(R) HD Graphics 4600
EW is the value for the effective width (1920 / 1.25).

You use GetSystemMetrics(SM_CXScreen) which should be correct.
When I call GetDisplayModeString within my software then the return string is correct.

Btw. the attached screenshot had in both cases a width of 1920.
Post Reply