DirectX SDK |
The DirectInputDevice.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.
object.SetCooperativeLevel(hwnd As Long, _ flags As CONST_DISCLFLAGS)
The following combinations of flags are valid:
Flags | Meaning | Valid for |
---|---|---|
DISCL_NONEXCLUSIVE Or DISCL_BACKGROUND | Others can acquire device in exclusive or nonexclusive mode; your application has access to data at all times. | All. |
DISCL_NONEXCLUSIVE Or DISCL_FOREGROUND | Others can acquire device in exclusive or nonexclusive mode; your application has access to data only when in the foreground. | All. |
DISCL_EXCLUSIVE Or DISCL_BACKGROUND | Others can acquire device in nonexclusive mode; your application has access to data at all times. | Joystick. |
DISCL_EXCLUSIVE Or DISC_FOREGROUND | Others can acquire device in nonexclusive mode; your application has access to data only when in the foreground. | All. Valid for mouse but prevents Windows from displaying the cursor. |
If the method fails, an error is raised and Err.Number may be one of the following error codes:
DIERR_INVALIDPARAM |
DIERR_INVALIDHANDLE |
No two applications (or instances of the same application) can have a device acquired in exclusive mode at the same time. This is primarily a security feature; it prevents input intended for one application from going to another that may be running concurrently.
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 DirectInputDevice.Acquire method.