forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting Screen Resolution

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
ljfarrugia



Joined: 06 Jun 2016
Posts: 19

PostPosted: Thu Jun 09, 2016 10:11 pm    Post subject: Getting Screen Resolution Reply with quote

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
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 5046
Location: Salford, UK

PostPosted: Fri Jun 10, 2016 7:07 am    Post subject: Reply with quote

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
Code:
 i = SetDpiAwareness@(1)


See cwplus.enh for details.
Back to top
View user's profile Send private message
ljfarrugia



Joined: 06 Jun 2016
Posts: 19

PostPosted: Fri Jun 10, 2016 4:50 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 5046
Location: Salford, UK

PostPosted: Fri Jun 10, 2016 6:49 pm    Post subject: Reply with quote

Yes it can be used safely. The function returns 0 if the operating system is before Windows 8.1.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group