How to get the current resolution size of the 2nd monitor?

L

lucy

Hi all,

I am having two monitor displays. I want to know the current resolution
(horizontal number of pixels x vertical number of pixels) of the second
monitor? How to do that?

If it is the primary display, I can easily get its current resolution using
the following apporach.

XRes= (double)GetSystemMetrics(SM_CXSCREEN);
YRes= (double)GetSystemMetrics(SM_CYSCREEN);

But how to do that for the second monitor?

Also, how to set the second monitor to a certain resolution? For example,
how to first enumerate its resolution list and pick an supported resolution
to switch the current resolution to that target resolution?

thanks a lot
 
C

Calvin Guan

Use EnumDisplayDevices to enumerate all active desktops, the use
EnumDisplaySettings(Ex) on desired desktop(s).

HTH,
calvin
 
A

ALEXB

lucy said:
Hi all,

I am having two monitor displays. I want to know the current resolution
(horizontal number of pixels x vertical number of pixels) of the second
monitor? How to do that?

If it is the primary display, I can easily get its current resolution using
the following apporach.

XRes= (double)GetSystemMetrics(SM_CXSCREEN);
YRes= (double)GetSystemMetrics(SM_CYSCREEN);

But how to do that for the second monitor?

Also, how to set the second monitor to a certain resolution? For example,
how to first enumerate its resolution list and pick an supported resolution
to switch the current resolution to that target resolution?

thanks a lot

Manually you can go to Start-->Settings-->Control Panel-->Display-->Settings
and you will see both of your monitors schematically represented by two
rectangles. Click on either of them and the actually resolution will be
displayed. I suspect you probably know it all and you are looking for a
command to do it programmatically? Yes?
 
Joined
Jul 8, 2005
Messages
1
Reaction score
0
Alternatively, you could find out the device context of your secondary monitor and call GetDeviceCaps(dc , HOZRES/VERTRES);

(with dc being the variable holding the handle to the dc, of course)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top