IDirectDraw::SetCooperativeLevel

HRESULT SetCooperativeLevel(HWND hWnd, DWORD dwFlags);

Determines the top-level behavior of the application.

·Returns DD_OK if successful, or one of the following error values otherwise:

DDERR_HWNDALREADYSET DDERR_INVALIDPARAMS
DDERR_HWNDSUBCLASSED DDERR_INVALIDOBJECT
DDERR_EXCLUSIVEMODEALREADYSET DDERR_OUTOFMEMORY

hWnd

Specifies the window handle used for the application.

dwFlags

DDSCL_ALLOWMODEX

Allows the use of ModeX display modes.

DDSCL_ALLOWREBOOT

Allows CTRL_ALT_DEL to function while in full screen exclusive mode.

DDSCL_EXCLUSIVE

Requests the exclusive level.

DDSCL_FULLSCREEN

Indicates that the exclusive mode owner will be responsible for the entire primary surface. GDI can be ignored.

DDSCL_NORMAL

Indicates that the application will function as a regular Windows application.

DDSCL_NOWINDOWCHANGES

Indicates that DirectDraw is not allowed to minimize or restore the application window on activation.

The DDSCL_EXCLUSIVE flag must be set to call functions that can have drastic performance consequences for other applications. To call the IDirectDraw::Compact method, change the display mode, or modify the behavior (for example, flipping) of the primary surface, an application must be set to the exclusive level. If an application calls the IDirectDraw::SetCooperativeLevel method with DDSCL_EXCLUSIVE and DDSCL_FULLSCREEN flags set, DirectDraw will attempt to resize its window to full screen. An application must either set the DDSCL_EXCLUSIVE or DDSCL_NORMAL flags, and DDSCL_EXCLUSIVE requires DDSCL_FULLSCREEN.

ModeX modes are only available if an application sets DDSCL_ALLOWMODEX, DDSCL_FULLSCREEN, and DDSCL_EXCLUSIVE. DDSCL_ALLOWMODEX cannot be used with DDSCL_NORMAL. If DDSCL_ALLOWMODEX is not specified, the IDirectDraw2::EnumDisplayModes method will not enumerate the ModeX modes, and the IDirectDraw2::SetDisplayMode method will fail when a ModeX mode is requested. The set of supported display modes may change after using IDirectDraw::SetCooperativeLevel.

ModeX modes are not supported by Windows; therefore, when in a ModeX mode you cannot use the IDirectDrawSurface::Lock method to lock the primary surface, or the IDirectDrawSurface::Blt method to blit to the primary surface. Use the IDirectDrawSurface::GetDC method on the primary surface, or use GDI with a screen DC. ModeX modes are indicated by the DDSCAPS_MODEX flag in the DDSCAPS member of the DDSURFACEDESC structure returned by the IDirectDrawSurface::GetCaps and IDirectDraw2::EnumDisplayModes methods.

Because applications can use DirectDraw with multiple windows, IDirectDraw::SetCooperativeLevel does not require an HWND to be specified if the application is requesting the DDSCL_NORMAL mode. By passing a NULL to HWND, all of the windows can be used simultaneously in normal Windows mode.