CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 17

Threaded View

  1. #1
    Join Date
    Sep 2007
    Location
    poland|wrocław
    Posts
    47

    [solved] SetWindowsHookEx stop receivings notifications after focus lost

    Good evening

    I've search a lot of forums but did not found any answer to my question. So here I post it.

    I'm trying to set hook to keyboard to receive all multimedia keys notification, for altering they default behavior or simply disable them. But I've run into some problem.

    In my .exe file I call functions from .dll which simply sets the hook with this code
    Code:
    SetWindowsHookEx( WH_SHELL, ShellProc, gModule, 0 );
    Then goes the handling like this
    Code:
    LRESULT CALLBACK ShellProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
        if (nCode >= 0 )
        {
            switch( wParam )
            {
                 // here I would like to handle WH_SHELL -> HSHELL_APPCOMMAND -> ie. APPCOMMAND_LAUNCH_APP2
            }
        } // if
        return CallNextHookEx (gHookProc, nCode, wParam, lParam);
    }
    Everything works correctly to the moment o losing the focus, after that my application simply stops receiving the notifications. When setting the focus back to my app it start working again.
    Do I need to set up sth more? Switch sth in the system? Disable sth?

    I use the m$ way to link the .exe with .dll with dllimport/dllexport. No dynamic load of .dll.
    My system is Vista64. I don't have any drivers for my keyboard I use the ones that comes with vista.

    Please help.
    J.



    //EDIT: syntax error fix
    Last edited by macabre13; January 29th, 2009 at 03:34 AM. Reason: solved

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured