IDirectDraw7::SetCooperativeLevel
The IDirectDraw7::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_ALLOWMODEX
- Allows the use of display modes. This flag can only be used if the DDSCL_EXCLUSIVE and DDSCL_FULLSCREEN flags are present.
- DDSCL_ALLOWREBOOT
- Allows CTRL+ALT+DEL to function while in exclusive (full-screen) mode.
- DDSCL_CREATEDEVICEWINDOW
- This flag is supported in Microsoft® Windows® 98 and Microsoft® Windows® 2000 only. Indicates that DirectDraw is to create and manage a default for this DirectDraw object. For more information, see Focus and Device Windows.
- DDSCL_EXCLUSIVE
- Requests the exclusive level. This flag must be used with the DDSCL_FULLSCREEN flag.
- DDSCL_FPUPRESERVE
- The calling application cares about the FPU state and does not want Direct3D to modify it in ways visible to the application. In this mode, Direct3D saves and restores the FPU state every time that it needs to modify the FPU state. For more information, see DirectDraw Cooperative Levels and FPU Precision.
- DDSCL_FPUSETUP
- 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. This is the default state. For more information, see DirectDraw Cooperative Levels and FPU Precision.
- DDSCL_FULLSCREEN
- The exclusive-mode owner is responsible for the entire . The GDI can be ignored. This flag must be used with the DDSCL_EXCLUSIVE flag.
- DDSCL_MULTITHREADED
- Requests multithread-safe DirectDraw behavior. This causes Direct3D to take the global critical section more frequently.
- DDSCL_NORMAL
- The application functions as a regular Microsoft® Windows® application. This flag cannot be used with the DDSCL_ALLOWMODEX, DDSCL_EXCLUSIVE, or DDSCL_FULLSCREEN flags.
- DDSCL_NOWINDOWCHANGES
- 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 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 for this DirectDraw object. This flag cannot be used with the DDSCL_SETDEVICEWINDOW flag.
Return Values
If the method succeeds, the return value is DD_OK.
If it fails, the method can return one of the following error values:
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. For more information, see Cooperative Levels.
Interaction between this method and the IDirectDraw7::SetDisplayMode method differs from their IDirectDraw counterparts. For more information, see Restoring Display Modes.
If you use Microsoft Foundation Classes (MFC), 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, you could use the following code:
HWND hwndTop = AfxGetMainWnd()->GetSafeHwnd();
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 98.
Header: Declared in ddraw.h.
See Also
IDirectDraw7::SetDisplayMode, IDirectDraw7::Compact, IDirectDraw7::EnumDisplayModes, Mode X and Mode 13 Display Modes, Focus and Device Windows