The IDirectInputDevice::SetCooperativeLevel method establishes the cooperative level for this instance of the device. The cooperative level determines how this instance of the device interacts with other instances of the device and the rest of the system.
HRESULT SetCooperativeLevel(
HWND hwnd,
DWORD dwFlags
);
DISCL_BACKGROUND | |
The application requires background access. If background access is granted, the device may be acquired at any time, even when the associated window is not the active window. | |
DISCL_EXCLUSIVE | |
The application requires exclusive access. If exclusive access is granted, no other instance of the device may obtain exclusive access to the device while it is acquired. Note, however, non-exclusive access to the device is always permitted, even if another application has obtained exclusive access. | |
An application that acquires the mouse or keyboard device in exclusive mode should always unacquire the devices when it receives WM_ENTERSIZEMOVE and WM_ENTERMENULOOP messages. Otherwise, the user will not be able to manipulate the menu or move and resize the window. | |
DISCL_FOREGROUND | |
The application requires foreground access. If foreground access is granted, the device is automatically unacquired when the associated window moves to the background. | |
DISCL_NONEXCLUSIVE | |
The application requires non-exclusive access. Access to the device will not interfere with other applications that are accessing the same device. |
Applications must specify either DISCL_FOREGROUND or DISCL_BACKGROUND; it is an error to specify both or neither. Similarly, applications must specify either DISCL_EXCLUSIVE or DISCL_NONEXCLUSIVE.
If the method succeeds, the return value is DI_OK.
If the method fails, the return value may be one of the following error values:
DIERR_INVALIDPARAM |
DIERR_NOTINITIALIZED |
If the system mouse is acquired in exclusive mode, then the pointer will be removed from the screen until the device is unacquired.
Applications must call this method before acquiring the device by using the IDirectInputDevice::Acquire method.
Windows NT: Use version 5.0 or later.
Windows: Use Windows 95 or later. Available as a redistributable for Windows 95.
Windows CE: Unsupported.
Header: Declared in dinput.h.
Import Library: Use dinput.lib.