Archived

This topic is now archived and is closed to further replies.

Enumerating display modes using WIN32 not DX.

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I want to be able to get the name of the device and all the resolutions available of the device, using regular WIN32 methods and not DX. Then I want to be able to list these in a list box. Is there any example out there? I am doing this because I am using OGL and I don''t want to use DX.

Share this post


Link to post
Share on other sites
Here's an example using two functions, EnumDisplayDevices() and EnumDisplaySettings(). Note that EnumDisplayDevices() requires Win 98 or Win 2000. Therefore, WINVER is defined as 0x0500 as MS header files require to target those two platforms (refer to http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/sdkintro/guide_04qb.htm for more info on that). This little program enumerates every display device available and every possible resolution/color depth for each device, spitting the info out to a series of message boxes.

                                    
#define WINVER 0x0500

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int iCmdShow)
{

DWORD iDevNum = 0 ;
DWORD iModeNum = 0 ;
DISPLAY_DEVICE ddi ;
DEVMODE dmi ;
TCHAR szBuffer [100] ;

ZeroMemory (&ddi, sizeof(ddi)) ;
ddi.cb = sizeof(ddi) ;
ZeroMemory (&dmi, sizeof(dmi)) ;
dmi.dmSize = sizeof(dmi) ;

while (EnumDisplayDevices (NULL, iDevNum++, &ddi, 0))
{
while (EnumDisplaySettings (ddi.DeviceName, iModeNum++, &dmi))
{
wsprintf (szBuffer, "Display device %s: %ix%ix%i.",
ddi.DeviceString, dmi.dmPelsWidth,
dmi.dmPelsHeight, dmi.dmBitsPerPel) ;
MessageBox (NULL, szBuffer, APPNAME, MB_OK) ;
ZeroMemory (&dmi, sizeof(dmi)) ;
dmi.cb = sizeof(dmi) ;

}
ZeroMemory (&ddi, sizeof(ddi)) ;
ddi.cb = sizeof(ddi) ;
iModeNum = 0 ;
}

return 1 ;

}


Edited by - Steel on October 4, 2000 9:06:16 PM

Share this post


Link to post
Share on other sites