IDirectDraw2::SetDisplayMode

The IDirectDraw2::SetDisplayMode method sets the mode of the display-device hardware.

HRESULT SetDisplayMode(
  DWORD dwWidth,        
  DWORD dwHeight,       
  DWORD dwBPP,          
  DWORD dwRefreshRate,  
  DWORD dwFlags         
);
 

Parameters

dwWidth and dwHeight
Width and height of the new mode.
dwBPP
Bits per pixel (bpp) of the new mode.
dwRefreshRate
Refresh rate of the new mode. If this parameter is set to 0, the IDirectDraw interface version of this method is used.
dwFlags
Flags describing additional options. Currently, the only valid flag is DDSDM_STANDARDVGAMODE, which causes the method to set Mode 13 instead of Mode X 320x200x8 mode. If you are setting another resolution, bit depth, or a Mode X mode, do not use this flag and set the parameter to 0.

Return Values

If the method succeeds, the return value is DD_OK.

If the method fails, the return value may be one of the following error values:

DDERR_GENERIC
DDERR_INVALIDMODE
DDERR_INVALIDOBJECT
DDERR_INVALIDPARAMS
DDERR_LOCKEDSURFACES
DDERR_NOEXCLUSIVEMODE
DDERR_SURFACEBUSY
DDERR_UNSUPPORTED
DDERR_UNSUPPORTEDMODE
DDERR_WASSTILLDRAWING

Remarks

If another application changes the display mode, the primary surface will be lost and will return DDERR_SURFACELOST until it is recreated to match the new display mode.

As part of the IDirectDraw interface, this method did not include the dwRefreshRate and dwFlags parameters.

QuickInfo

  Windows NT: Use version 4.0 or later.
  Windows: Use Windows 95 or later. Available as a redistributable for Windows 95.
  Windows CE: Unsupported.
  Header: Declared in ddraw.h.
  Import Library: Use ddraw.lib.

See Also

IDirectDraw2::RestoreDisplayMode, IDirectDraw2::GetDisplayMode, IDirectDraw2::EnumDisplayModes, IDirectDraw2::SetCooperativeLevel, Cooperative Levels and Display Modes with IDirectDraw2, Setting Display Modes