Platform SDK: DirectX |
The information in this topic pertains only to applications written in C++. See DirectInput Visual Basic Tutorials.
Before it can gain access to the mouse, your application must set the mouse device's behavior using the IDirectInputDevice7::SetCooperativeLevel method. This method accepts the handle to the window to be associated with the device. In Scrawl, the DISCL_EXCLUSIVE flag is included to ensure that this application is the only one that can have exclusive access to the device. This flag is combined with DISCL_FOREGROUND because Scrawl is not interested in what the mouse is doing when another application is in the foreground.
The following code attempts to set the device's cooperative level. If this attempt fails, FALSE is returned.
hr = g_pMouse->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND); if (FAILED(hr)) { return FALSE; }