DirectInput lost with Alt-Tab
Whenever my game loses focus (like if the user hits Alt-Tab or Ctrl-Alt-Del) DirectInput loses control of the mouse and keyboard. This is understandable but the problem is regaining control after the game regains system focus.
I've tried catching WM_ACTIVATEAPP messages and reinitializing based on the wParam but it still isn't working.
Anybody else ever have to deal with this? Any tricks of the trade I'm missing?
Here's the relevant parts of the code:
Code:
//in my MsgProc
case WM_ACTIVATEAPP:
{
if(!(int)wparam==0)
{
InitDI(hWnd,hInst); //hWnd and hInst are just the global
//HWND/HINSTANCE for my window
}
return(0);
}break;
InitDI() is just a basic DirectInput set-up function. Everything works fine until the game loses focus. The only other option I know of would be to check for WM_SYSCHAR messages and hook them so that the user can use Alt-Tab or Ctrl-Alt-Del but that's the last thing I want to do.
Thanks in advance for any help you can give.