# EnumDisplaySettings

This topic is 4388 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 )
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
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 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 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 on other sites
Here's waht I get with my code :

ATI MOBILITY RADEON 9600/9700 Series 640x480x16@60640x480x16@72640x480x16@75640x480x16@85640x480x16@90640x480x16@100640x480x16@120640x480x16@160640x480x16@200640x480x32@60640x480x32@72640x480x32@75640x480x32@85640x480x32@90640x480x32@100640x480x32@120640x480x32@160640x480x32@200800x600x16@60800x600x16@70800x600x16@72800x600x16@75800x600x16@85800x600x16@90800x600x16@100800x600x16@120800x600x16@160800x600x16@200800x600x32@60800x600x32@70800x600x32@72800x600x32@75800x600x32@85800x600x32@90800x600x32@100800x600x32@120800x600x32@160800x600x32@2001024x768x16@601024x768x16@701024x768x16@721024x768x16@751024x768x16@851024x768x16@901024x768x16@1001024x768x16@1201024x768x16@1501024x768x16@1601024x768x16@2001024x768x32@601024x768x32@701024x768x32@721024x768x32@751024x768x32@851024x768x32@901024x768x32@1001024x768x32@1201024x768x32@1501024x768x32@1601024x768x32@2001280x900x16@601280x900x32@601280x1024x16@601280x1024x16@701280x1024x16@751280x1024x16@851280x1024x16@901280x1024x16@1001280x1024x16@1201280x1024x16@1601280x1024x16@1801280x1024x32@601280x1024x32@701280x1024x32@751280x1024x32@851280x1024x32@901280x1024x32@1001280x1024x32@1201280x1024x32@1601280x1024x32@1801440x900x16@601440x900x32@601600x1200x16@601600x1200x16@751600x1200x16@851600x1200x16@1001600x1200x16@1201600x1200x32@601600x1200x32@751600x1200x32@851600x1200x32@1001600x1200x32@1201792x1344x16@601792x1344x16@751792x1344x16@901792x1344x16@1001792x1344x32@601792x1344x32@751792x1344x32@901792x1344x32@1001800x1440x16@601800x1440x16@701800x1440x16@901800x1440x16@1001800x1440x32@601800x1440x32@701800x1440x32@901800x1440x32@1001920x1080x16@601920x1080x16@751920x1080x16@1001920x1080x16@1201920x1080x32@601920x1080x32@751920x1080x32@1001920x1080x32@1201920x1200x16@601920x1200x16@751920x1200x16@851920x1200x16@1001920x1200x32@601920x1200x32@751920x1200x32@851920x1200x32@1001920x1440x16@601920x1440x16@751920x1440x16@851920x1440x16@901920x1440x32@601920x1440x32@751920x1440x32@851920x1440x32@902048x1536x16@602048x1536x16@662048x1536x16@702048x1536x16@752048x1536x16@852048x1536x32@602048x1536x32@662048x1536x32@702048x1536x32@752048x1536x32@85

I don't get what You want.

##### Share on other sites
Quote:
 Original post by iliakHere'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@60640x480x16@72640x480x16@75640x480x32@60640x480x32@72640x480x32@75720x480x16@60720x480x16@75720x480x32@60720x480x32@75720x576x16@59720x576x16@60720x576x16@75720x576x32@59720x576x32@60720x576x32@75800x600x16@56800x600x16@60800x600x16@70800x600x16@72800x600x16@75800x600x32@56800x600x32@60800x600x32@70800x600x32@72800x600x32@75848x480x16@60848x480x16@75848x480x32@60848x480x32@751024x768x16@601024x768x16@701024x768x16@721024x768x16@751024x768x32@601024x768x32@701024x768x32@721024x768x32@751152x864x16@601152x864x16@701152x864x16@751152x864x32@601152x864x32@701152x864x32@751280x720x16@601280x720x16@751280x720x32@601280x720x32@751280x768x16@601280x768x16@751280x768x32@601280x768x32@751280x960x16@601280x960x16@701280x960x16@721280x960x16@751280x960x32@601280x960x32@701280x960x32@721280x960x32@751280x1024x16@601280x1024x16@701280x1024x16@751280x1024x32@601280x1024x32@701280x1024x32@75Press 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 on other sites
did you tried your code on other computers than yours ?
Just send an executable to test...

• 32
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631352
• Total Posts
2999483
×