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

Thread: Converting MouseProc Hook to lpfnWndProc message

  1. #1
    Join Date
    May 2008
    Posts
    8

    Converting MouseProc Hook to lpfnWndProc message

    Ok, I've a DLL that's hooked to pick up all Mouse and Keyboard events in it. What I then want to do is through all those to another window. I understand how to do simulate these events, with PostMessage and SendMessage, to the HWND, but what I'd like to do is automatically convert these into a compatible lpfnWndProc message.

    Generating the UINT is easy enough, because that can be obtained in the hooks, as the WPARAM identifier. The values for LPARAM and wParam for Keyboard is also easy, but I've no idea how to get the lParam for mouse events.

    From MSDN, it says that it
    Indicates whether various virtual keys are down. This parameter can be one or more of the following values.

    MK_CONTROL
    The CTRL key is down.
    MK_LBUTTON
    The left mouse button is down.
    MK_MBUTTON
    The middle mouse button is down.
    MK_RBUTTON
    The right mouse button is down.
    MK_SHIFT
    The SHIFT key is down.
    MK_XBUTTON1
    Windows 2000/XP: The first X button is down.
    MK_XBUTTON2
    Windows 2000/XP: The second X button is down.
    I can't see any way of getting this information from within the hooks, without keeping a static record of whether these keys were pressed already. Is there another way that I can get that information, do any of you know?

  2. #2
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,917

    Re: Converting MouseProc Hook to lpfnWndProc message

    Quote Originally Posted by seaders View Post
    Ok, I've a DLL that's hooked to pick up all Mouse and Keyboard events in it
    First of all, windows hook (you are referring to such, right?) does not "pick" mouse nor keyboard events.
    It (depending on the hook) is called with certain windows messages and delivers additional information, usually in a form of specific structure. Hardware events like a keypress or mouse movement generate windows messages delivered to a window that has focus, or mouse is hovering over.
    Quote Originally Posted by seaders View Post
    I understand how to do simulate these events, with PostMessage and SendMessage, to the HWND,
    You would be better off using SendInput API. Send- or PostMessage should not be used; besides you would not achieve desired results even if you did. You do not send a message to HWND. Message is send to a window identified by a handle.
    Quote Originally Posted by seaders View Post
    but what I'd like to do is automatically convert these into a compatible lpfnWndProc message.
    Can you define "compatible lpfnWndProc" message?
    Quote Originally Posted by seaders View Post
    Generating the UINT is easy enough,
    I am even more confused here. What is "generating UINT"?
    Quote Originally Posted by seaders View Post
    I can't see any way of getting this information from within the hooks, without keeping a static record of whether these keys were pressed already. Is there another way that I can get that information, do any of you know?
    Are you sure you are referring to Windows hook?
    I think the best way to find a solution to your problem is:
    1. Explain it in simple words.
    2. Post a project you are working on.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

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)