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

Thread: SetWindowsHookEx stops receiving WH_MOUSE_LL notifications after focus lost

  1. #1
    Join Date
    Oct 2020
    Posts
    1

    SetWindowsHookEx stops receiving WH_MOUSE_LL notifications after focus lost

    Hi, I found this forum by stumbling onto the similar question here.
    The difference is, that in my case I have a SetWindowsHookEx in a simple c++ program, not a dll. The program creates an SDL2 window. But when that window loses focus, the SetWindowsHookEx stops receiving WH_MOUSE_LL messages.
    I tried to include the code snippet suggested by Igor Vartanov in the link above, but it did not help in my case.

    Any suggestion on how to make SetWindowsHookEx continue receiving WH_MOUSE_LL messages after focus of the SDL2 window is lost?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,401

    Re: SetWindowsHookEx stops receiving WH_MOUSE_LL notifications after focus lost

    Your hook doesn't stop working per se, it's just that Windows quits sending mouse messages to your window when it's lost focus.

    You have at least two options:
    1) keep your app in focus
    2) use a global hook

  3. #3
    Join Date
    Nov 2020
    Posts
    1

    Re: SetWindowsHookEx stops receiving WH_MOUSE_LL notifications after focus lost

    i have the same issue but where to find global hook

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,325

    Re: SetWindowsHookEx stops receiving WH_MOUSE_LL notifications after focus lost

    Re global hooks. See https://docs.microsoft.com/en-us/win...sg/using-hooks

    The global hook has to be in a separate dll.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.8.2)

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)