Retrieving monitor resolution

Posted By: TehV

Retrieving monitor resolution - 01/03/14 10:40

Hi,
I'm currently struggling with one of my menu screens - more specifically, the settings menu, where the user should be allowed to set their screen's resolution.
I have two problems with this:
-For one, I don't know the actual screen resolution, nor what resolutions are actually supported by their graphics device.
-Secondly, the application doesn't necessarily run on the primary monitor, so I need to be able to get the possible resolutions for the monitor that the application is being displayed on.

What I'm trying to do is create a drop-down menu where users can select the screen resolution they want. I want to include all resolutions their graphics device supports, and only those (no point in including a 1920x1080 option if their screen has a resolution of 1024x768, right?).

Is this possible? If so, how would I do this?

Thanks in advance,
~TehV
Posted By: oliver2s

Re: Retrieving monitor resolution - 01/03/14 10:49

The actual screen resolution can be got with sys_metrics(0) and sys_metrics(1), see http://www.conitec.net/beta/asys_metrics.htm
Posted By: TehV

Re: Retrieving monitor resolution - 01/03/14 11:10

Thanks!
The manual says that those are the X and Y sizes of the primary monitor. Is it possible to retrieve the size of the second monitor using this function as well?

EDIT: The sys_metrics function appears to give me the wrong values. My screen resolution is 1920x1080, but sys_metrics gives me a resolution of 720x480.
Posted By: Ch40zzC0d3r

Re: Retrieving monitor resolution - 01/03/14 12:04

Then use windows APIs, a short google session will help you out laugh
BTW you should run it BEFORE you start your game in fullscreen tongue
Posted By: TehV

Re: Retrieving monitor resolution - 01/03/14 17:10

Running those functions before switching to fullscreen did the trick, I'm now getting the correct values. Should have seen that. Thanks!

I've tried to avoid using the Windows API but I'll have a look at it.

EDIT: For the resolution of the secondary monitor, one seems to have to go a bit of a detour:

Code:
var monitor2size_x = sys_metrics(78) - sys_metrics(0);
var monitor2size_y = sys_metrics(79);



Of course, this only works if the secondary monitor is larger in the Y direction than the primary monitor. If it is not, then the resolution will be incorrect in the Y direction.
I will investigate further to see if I can find a workaround to this.
© 2024 lite-C Forums