Silverfrost Forums

Welcome to our forums

Getting Screen Resolution

9 Jun 2016 9:11 #17616

For years I have been using the API function GetSystemMetrics with Clearwin to get the current screen resolution, in order to decide on the size of graphics windows

Is there a better way? On one of my laptops GetSytemMetrics reports a screen resolution of 1280x720, but Windows says the resolution is actually 1920x1080

10 Jun 2016 6:07 #17617

You may need to enable DP! awareness.

If you are using the latest release and your program has done something in ClearWin+ then DPI awareness will be on (Process_System_DPI_Aware) by default (but you need to be running Windows 8.1 or later).

Otherwise you can use the call

 i = SetDpiAwareness@(1)

See cwplus.enh for details.

10 Jun 2016 3:50 #17622

Thanks, that works perfectly

What is the effect of a call SetDpiAwareness(1) if the operating system is earlier than Win 8.1 ?, i.e. can it be used safely in any program without checking the Windows version?

10 Jun 2016 5:49 #17624

Yes it can be used safely. The function returns 0 if the operating system is before Windows 8.1.

Please login to reply.