|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.|
Because display hardware varies, not all devices will support all display modes. To determine the display modes supported on a given system, call the IDirectDraw4::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 DDSURFACEDESC2structure that describes a given display mode to be confirmed; you'll 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 don't 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 DDSURFACEDESC2structure 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 DDSURFACEDESC2structure 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 the dwFlagsmember contains the DDPF_PALETTEINDEXED1, DDPF_PALETTEINDEXED2, DDPF_PALETTEINDEXED4, or DDPF_PALETTEINDEXED8 flag, the display mode's bit depth is 1, 2, 4 or 8 bits, and each pixel is an index into an associated palette. If dwFlagscontains DDPF_RGB, then the display mode is non-palettized and its bit depth is provided in the dwRGBBitCountmember of the DDPIXELFORMATstructure.
Last updated on Tuesday, May 18, 2004