Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

Because display hardware varies, not all devices will support all display modes. To determine the display modes supported on a given system, call the IDirectDraw::EnumDisplayModesmethod.

By setting the appropriate values and flags, the EnumDisplayModesmethod can list all supported display modes or confirm that a single display mode that you specify is supported.

The method's first parameter, dwFlags, controls extra options for the method; in most cases, you will set dwFlagsto 0 to ignore extra options.

The second parameter, lpDDSurfaceDesc, is the address of a DDSURFACEDESCstructure that describes a given display mode to be confirmed; you will usually set this parameter to NULL to request that all modes be listed.

The third parameter, lpContext, is a pointer that you want DirectDraw to pass to your callback function; if you do not need any extra data in the callback function, use NULL here.

Last, you set the lpEnumModesCallbackparameter to the address of the callback function that DirectDraw will call for each supported mode.

The callback function you supply when calling EnumDisplayModesmust match the prototype for the EnumModesCallbackfunction.

For each display mode that the hardware supports, DirectDraw calls your callback function passing two parameters.

The first parameter is the address of a DDSURFACEDESCstructure that describes one supported display mode, and the second parameter is the address of the application-defined data you specified when calling EnumDisplayModes, if any.

Examine the values in the DDSURFACEDESCstructure to determine the display mode it describes. The key structure members are the dwWidth, dwHeight, and ddpfPixelFormatmembers.

The dwWidthand dwHeightmembers describe the display mode's dimensions, and the ddpfPixelFormatmember is a DDPIXELFORMATstructure that contains information about the mode's bit depth.

The DDPIXELFORMATstructure carries information describing the mode's bit depth and tells you whether or not the display mode uses a palette.

If dwFlagscontains DDPF_RGB, then the display mode is non-palettized and its bit depth is provided in the dwRGBBitCountmember of the DDPIXELFORMATstructure.