Sign in to follow this  
Endar

EnumDisplaySettings

Recommended Posts

I'm attempting to get all the possible resolutions for the display device.
std::vector<std::pair<int,int> > dev_resolution_list;
DEVMODE dev_mode;	// to store the device mode in
// get all the possible screen resolutions (using NULL as the string just sets it to the current display device)
for(int mode=0; EnumDisplaySettings(NULL, mode, &dev_mode) != 0; ++mode){
	if( !dev_resolution_list.empty() ){
		std::pair<int,int> p(dev_mode.dmPelsWidth, dev_mode.dmPelsHeight);
		// since we only care about the size of the screen, and not the frequency or anything else,
		// only add if we have a unique screen res
		int i;	// use this to check
		for(i=0; i < dev_resolution_list.size(); ++i)
			if( p == dev_resolution_list[i] )
				break;
 
		// If the resolution is already in the list, then the value of 'i' will be
		//		less than 'dev_resolution_list.size()'.
		// Else if the resolution is NOT present in the list, then the value of 'i' will be
		//		equal to 'dev_resoltion_list.size()'.
		if( i == dev_resolution_list.size() )
			dev_resolution_list.push_back( p );
	}
	// Else we don't have anything yet, so add the first one
	else
		// add the resolution
		dev_resolution_list.push_back( std::pair<int,int>(dev_mode.dmPelsWidth, dev_mode.dmPelsHeight) ); 
}

I'm trying to do it like this, but I'm having problems in the fact that it's not enumerating everything. Doing this, the largest resolution I get is 1280x1024, but when I take a look at the desktop settings I get as high as 2048x1536. What's going on here?

Share this post


Link to post
Share on other sites
Here's my code to enumerate all screen resolutions :



//
// Recuperation des ecrans et modes d'affichages disponibles
//
DISPLAY_DEVICE display;
int displaynum = 0;
memset(&display, 0, sizeof(display));
display.cb = sizeof(display);

// Liste des moniteurs installes
while(EnumDisplayDevices(NULL, displaynum++, &display, NULL))
{
// Moniteur de rendu
if (display.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
{
log << display.DeviceString;

DEVMODE devmode;
memset(&devmode, 0, sizeof(devmode));
devmode.dmSize = sizeof(devmode);
int num = 0;
while (EnumDisplaySettings(display.DeviceName, num++, &devmode))
{
if (devmode.dmBitsPerPel >=16 && devmode.dmPelsWidth >= 640 && devmode.dmPelsHeight >= 480)
{
ScreenModes.push_back(devmode);
log << devmode.dmPelsWidth << "x" << devmode.dmPelsHeight << "x" << devmode.dmBitsPerPel << "@" << devmode.dmDisplayFrequency << NewLine;
}
}
}
}

Share this post


Link to post
Share on other sites
iliak, your code ends at the same place that mine does.

Are the higher resolutions in the desktop properties implemented differently than the lower ones? It could be that there are resolutions that the monitor supports, but more work has to be done for resolutions that are over the native resolution for a monitor.

Or something like that. I'm really just wildly swinging here.

Share this post


Link to post
Share on other sites
Here's waht I get with my code :


ATI MOBILITY RADEON 9600/9700 Series 640x480x16@60
640x480x16@72
640x480x16@75
640x480x16@85
640x480x16@90
640x480x16@100
640x480x16@120
640x480x16@160
640x480x16@200
640x480x32@60
640x480x32@72
640x480x32@75
640x480x32@85
640x480x32@90
640x480x32@100
640x480x32@120
640x480x32@160
640x480x32@200
800x600x16@60
800x600x16@70
800x600x16@72
800x600x16@75
800x600x16@85
800x600x16@90
800x600x16@100
800x600x16@120
800x600x16@160
800x600x16@200
800x600x32@60
800x600x32@70
800x600x32@72
800x600x32@75
800x600x32@85
800x600x32@90
800x600x32@100
800x600x32@120
800x600x32@160
800x600x32@200
1024x768x16@60
1024x768x16@70
1024x768x16@72
1024x768x16@75
1024x768x16@85
1024x768x16@90
1024x768x16@100
1024x768x16@120
1024x768x16@150
1024x768x16@160
1024x768x16@200
1024x768x32@60
1024x768x32@70
1024x768x32@72
1024x768x32@75
1024x768x32@85
1024x768x32@90
1024x768x32@100
1024x768x32@120
1024x768x32@150
1024x768x32@160
1024x768x32@200
1280x900x16@60
1280x900x32@60
1280x1024x16@60
1280x1024x16@70
1280x1024x16@75
1280x1024x16@85
1280x1024x16@90
1280x1024x16@100
1280x1024x16@120
1280x1024x16@160
1280x1024x16@180
1280x1024x32@60
1280x1024x32@70
1280x1024x32@75
1280x1024x32@85
1280x1024x32@90
1280x1024x32@100
1280x1024x32@120
1280x1024x32@160
1280x1024x32@180
1440x900x16@60
1440x900x32@60
1600x1200x16@60
1600x1200x16@75
1600x1200x16@85
1600x1200x16@100
1600x1200x16@120
1600x1200x32@60
1600x1200x32@75
1600x1200x32@85
1600x1200x32@100
1600x1200x32@120
1792x1344x16@60
1792x1344x16@75
1792x1344x16@90
1792x1344x16@100
1792x1344x32@60
1792x1344x32@75
1792x1344x32@90
1792x1344x32@100
1800x1440x16@60
1800x1440x16@70
1800x1440x16@90
1800x1440x16@100
1800x1440x32@60
1800x1440x32@70
1800x1440x32@90
1800x1440x32@100
1920x1080x16@60
1920x1080x16@75
1920x1080x16@100
1920x1080x16@120
1920x1080x32@60
1920x1080x32@75
1920x1080x32@100
1920x1080x32@120
1920x1200x16@60
1920x1200x16@75
1920x1200x16@85
1920x1200x16@100
1920x1200x32@60
1920x1200x32@75
1920x1200x32@85
1920x1200x32@100
1920x1440x16@60
1920x1440x16@75
1920x1440x16@85
1920x1440x16@90
1920x1440x32@60
1920x1440x32@75
1920x1440x32@85
1920x1440x32@90
2048x1536x16@60
2048x1536x16@66
2048x1536x16@70
2048x1536x16@75
2048x1536x16@85
2048x1536x32@60
2048x1536x32@66
2048x1536x32@70
2048x1536x32@75
2048x1536x32@85



I don't get what You want.

Share this post


Link to post
Share on other sites
Quote:
Original post by iliak
Here's waht I get with my code :

*** Source Snippet Removed ***

I don't get what You want.


I want the exact same output that you get.

Here's what I get:


RADEON 9600 SERIES 640x480x16@60
640x480x16@72
640x480x16@75
640x480x32@60
640x480x32@72
640x480x32@75
720x480x16@60
720x480x16@75
720x480x32@60
720x480x32@75
720x576x16@59
720x576x16@60
720x576x16@75
720x576x32@59
720x576x32@60
720x576x32@75
800x600x16@56
800x600x16@60
800x600x16@70
800x600x16@72
800x600x16@75
800x600x32@56
800x600x32@60
800x600x32@70
800x600x32@72
800x600x32@75
848x480x16@60
848x480x16@75
848x480x32@60
848x480x32@75
1024x768x16@60
1024x768x16@70
1024x768x16@72
1024x768x16@75
1024x768x32@60
1024x768x32@70
1024x768x32@72
1024x768x32@75
1152x864x16@60
1152x864x16@70
1152x864x16@75
1152x864x32@60
1152x864x32@70
1152x864x32@75
1280x720x16@60
1280x720x16@75
1280x720x32@60
1280x720x32@75
1280x768x16@60
1280x768x16@75
1280x768x32@60
1280x768x32@75
1280x960x16@60
1280x960x16@70
1280x960x16@72
1280x960x16@75
1280x960x32@60
1280x960x32@70
1280x960x32@72
1280x960x32@75
1280x1024x16@60
1280x1024x16@70
1280x1024x16@75
1280x1024x32@60
1280x1024x32@70
1280x1024x32@75


Press any key to continue . . .



But, when I take a look at the desktop settings (just right clicking on the desktop) the highest I can go is 2048x1536, so I'm mostly wondering why your code doesn't output up to that high on mine. It's obviously more to do with my computer than your code. I'm just trying to figure out what it is.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this