DirectX SDK

Setting Display Modes

You can set the display mode by using the IDirectDraw7::SetDisplayMode method in C++ or DirectDraw7.SetDisplayMode method in Visual Basic. The SetDisplayMode method accepts four parameters that describe the dimensions, bit depth, and refresh rate of the mode to be set. The method uses a fifth parameter to indicate special options for the given mode; this is currently only used to differentiate between Mode 13 and the Mode X 320×200×8 display mode.

[C++]

Although you can specify the desired display mode's bit depth, you cannot specify the pixel format that the display hardware will use for that bit depth. To determine the RGB bitmasks that the display hardware uses for the current bit depth, call IDirectDraw7::GetDisplayMode after setting the display mode. If the current display mode is not palettized, you can examine the mask values in the dwRBitMask, dwGBitMask, and dwBBitMask members in the DDPIXELFORMAT to determine the correct red, green, and blue bits. For more information, see Pixel Format Masks.

Modes can be changed by more than one application as long as they are all sharing a display card. You can change the bit depth of the display mode only if your application has exclusive access to the DirectDraw object. All DirectDrawSurface objects lose surface memory and become inoperative when the mode is changed. A surface's memory must be reallocated by using the IDirectDrawSurface7::Restore method.

The DirectDraw exclusive (full-screen) mode does not bar other applications from allocating DirectDrawSurface objects, nor does it exclude them from using DirectDraw or GDI functionality. However, it does prevent applications other than the one that obtained exclusive access from changing the display mode or palette.

Note  You can only call the IDirectDraw7::SetDisplayMode method from the thread that created the application window. For single threaded applications (the vast majority), this restriction isn't an issue.

[Visual Basic]

Although you can specify the desired display mode's bit depth, you cannot specify the pixel format that the display hardware will use for that bit depth. To determine the RGB bitmasks that the display hardware uses for the current bit depth, call DirectDraw7.GetDisplayMode after setting the display mode. If the current display mode is not palettized, you can examine the mask values in the lRBitMask, lGBitMask, and lBBitMask members of the DDPIXELFORMAT type to determine the correct red, green, and blue bits. For more information, see Pixel Format Masks.

Modes can be changed by more than one application as long as they are all sharing a display card. You can change the bit depth of the display mode only if your application has exclusive access to the DirectDraw object. All DirectDrawSurface objects lose surface memory and become inoperative when the mode is changed. A surface's memory must be reallocated by using the DirectDrawSurface7.Restore method.

The DirectDraw exclusive (full-screen) mode does not bar other applications from allocating DirectDrawSurface objects, nor does it exclude them from using DirectDraw or GDI functionality. However, it does prevent applications other than the one that obtained exclusive access from changing the display mode or palette.