Use of EnumDisplaySettings under VC++

Does anyone know how to use :
EnumDisplaySettings

I would like to display all the screen resolution available on my 3D card ?

I’m real newbie in windows programming, i know… :stuck_out_tongue_winking_eye:

I do it currently in the following way (not exactly that function, but a more tweaked one and + support for refresh rates on NT bases OS´es:

void EnumerateDisplayModes(void)
{
DEVMODE dm;
memset(&dm, 0, sizeof(DEVMODE));
dm.dmSize = sizeof(DEVMODE);
dm.dmFields= DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

DWORD TestWidth[5] = {640, 800, 1024, 1280, 1600};
DWORD TestHeight[5] = {480, 600, 768, 1024, 1200};
DWORD TestDepth[2] = {16, 32};
for(int i = 0, j = 0; i <= 4 && j <= 1; j++)
{
    dm.dmPelsWidth = TestWidth[i];
    dm.dmPelsHeight = TestHeight[i];
    dm.dmBitsPerPel = TestDepth[j];

    if(ChangeDisplaySettings(&dm, CDS_TEST) == DISP_CHANGE_SUCCESSFUL)
    {

// Mode OK process ist somehow
}

    if(j == 1)
    {
        j = -1;
        i++;
    }
}

}

One advice, if you are on a NT based OS you have to take care of DM_DISPLAYFREQUENCY if you do it good .

Diapolo

Originally posted by Diapolo:

One advice, if you are on a NT based OS you have to take care of DM_DISPLAYFREQUENCY if you do it good .

Diapolo

It works great,thanks a lot !
I’ll try to focus my attention on the display frequency :stuck_out_tongue_winking_eye: thanks

No problem .

Help and get helped!

Diapolo