IDirectDraw4::SetCooperativeLevel

The IDirectDraw4::SetCooperativeLevel method determines the top-level behavior of the application.

HRESULT SetCooperativeLevel(
HWND hWnd, 
DWORD dwFlags); 

Parameters

  • hWnd
    Window handle used for the application. Set to the calling application's top-level window handle (not a handle for any child windows created by the top-level window). This parameter can be NULL when the DDSCL_NORMAL flag is specified in the dwFlags parameter.

  • dwFlags
    One or more of the following flags:

    DDSCL_CREATEDEVICEWINDOW This flag is supported in Windows 98 and Windows 2000 only. Indicates that DirectDraw is to create and manage a default device window for this DirectDraw object.
    DDSCL_EXCLUSIVE Requests the exclusive level. This flag must be used with the DDSCL_FULLSCREEN flag.
    DDSCL_FPUSETUP Indicates that the calling application is likely to keep the FPU set up for optimal Direct3D performance (single precision and exceptions disabled) so Direct3D does not need to explicitly set the FPU each time.
    DDSCL_FULLSCREEN Indicates that the exclusive-mode owner will be responsible for the entire primary surface. GDI can be ignored. This flag must be used with the DDSCL_EXCLUSIVE flag.
    DDSCL_MULTITHREADED Requests multithread-safe DirectDraw behavior. This flag causes Direct3D to take the global critical section more frequently.
    DDSCL_NORMAL Indicates that the application will function as a regular Windows application. This flag cannot be used with the DDSCL_ALLOWMODEX, DDSCL_EXCLUSIVE, or DDSCL_FULLSCREEN flags.

    The current Windows CE implementation allows for processes with NORMAL level to access DirectDraw resources when there is a process in full-screen exclusive mode. Processes in NORMAL mode can access primary surfaces but are restricted with regard to flipping, creating complex primaries, and setting display modes. A process may go into full-screen exclusive mode if no other process is in exclusive mode, regardless of whether processes are running at a NORMAL level of cooperation.

    DDSCL_NOWINDOWCHANGES Indicates that DirectDraw is not allowed to minimize or restore the application window on activation.
    DDSCL_SETDEVICEWINDOW This flag is supported in Windows 98 and Windows 2000 only. Indicates that the hWnd parameter is the window handle of the device window for this DirectDraw object. This flag cannot be used with the DDSCL_SETFOCUSWINDOW flag.
    DDSCL_SETFOCUSWINDOW This flag is supported in Windows 98 and Windows 2000 only. Indicates that the hWnd parameter is the window handle of the focus window for this DirectDraw object. This flag cannot be used with the DDSCL_SETDEVICEWINDOW flag.
    DDSCL_ALLOWMODEX, DDSCL_ALLOWREBOOT, DDSCL_ALLOWSYSKEY These flags are not supported in Windows CE.

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_EXCLUSIVEMODEALREADYSET
DDERR_HWNDALREADYSET
DDERR_HWNDSUBCLASSED
DDERR_INVALIDOBJECT
DDERR_INVALIDPARAMS
DDERR_OUTOFMEMORY

Remarks

This method must be called by the same thread that created the application window.

An application must set either the DDSCL_EXCLUSIVE or the DDSCL_NORMAL flag.

The DDSCL_EXCLUSIVE flag must be set to call functions that can have drastic performance consequences for other applications.

Interaction between this method and the IDirectDraw4::SetDisplayMode method differs from their IDirectDraw counterparts.

Developers using Microsoft Foundation Classes (MFC) should keep in mind that the window handle passed to this method should identify the application's top-level window, not a derived child window.

To retrieve your MFC application's top level window handle, use the following code:

    HWND hwndTop = AfxGetMainWnd()->GetSafeHwnd();

Requirements

Runs on Versions Declared in Link to
Windows CE OS 2.12 or later. Version 2.12 requires DXPAK 1.0 or later. ddraw.h ddraw.lib

See Also

IDirectDraw4::SetDisplayMode, IDirectDraw4::Compact, IDirectDraw4::EnumDisplayModes

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.