DirectX SDK |
Because Windows might force your application to unacquire the keyboard when you have set the cooperative level to DISCL_FOREGROUND and the focus switches to another application, you should check for the DIERR_INPUTLOST return value from the IDirectInputDevice7::GetDeviceData or IDirectInputDevice7::GetDeviceState methods and attempt to reacquire the keyboard, if necessary. (See Acquiring Devices.)
Note You should not attempt to reacquire the keyboard on getting a DIERR_NOTACQUIRED error. If you do, you could get caught in an infinite loop: acquisition would fail, you would get another DIERR_NOTACQUIRED error, and so on.
Because Windows might force your application to unacquire the keyboard when you have set the cooperative level to DISCL_FOREGROUND and the focus switches to another application, you should check for the DIERR_INPUTLOST return value from the DirectInputDevice.GetDeviceData or the DirectInputDevice.GetDeviceStateKeyboard method and attempt to reacquire the keyboard, if necessary. (See Acquiring Devices.)
Note You should not attempt to reacquire the keyboard on getting a DIERR_NOTACQUIRED error. If you do, you could get caught in an infinite loop: acquisition would fail, you would get another DIERR_NOTACQUIRED error, and so on.