DirectInput lost with Alt-Tab

This is a discussion on DirectInput lost with Alt-Tab within the Game Programming forums, part of the General Programming Boards category; Whenever my game loses focus (like if the user hits Alt-Tab or Ctrl-Alt-Del) DirectInput loses control of the mouse and ...

  1. #1
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    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.

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Agh! Problem solved!

    I changed the code in my WinProc to:
    Code:
    case WM_ACTIVATE:
    {
       if((int)WA_ACTIVE==wParam)
       {
          AcquireDI();
       }
       return(0);
    }break;
    Thanks anyway!

  3. #3
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    >>Thanks anyway!

    You are welcome!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. D3DX - ALT + TAB / Drawing stuff
    By Tonto in forum Game Programming
    Replies: 8
    Last Post: 10-31-2006, 08:04 PM
  2. Tab Ordering of GUI Controls
    By cloudy in forum Windows Programming
    Replies: 2
    Last Post: 04-22-2006, 09:13 AM
  3. Visual C++
    By Golffor1 in forum C++ Programming
    Replies: 1
    Last Post: 08-04-2003, 04:30 PM
  4. code for Alt + Tab keys
    By Sumir in forum Windows Programming
    Replies: 2
    Last Post: 10-12-2002, 03:49 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21