Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Intercept all mouse event for a specified hwnd

Intercept all mouse event for a specified hwnd

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
24 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Mark Salsbery

    A mousehook seems like an overkill solution for getting all the mouse events for a window. Why not just get the messages in the window's windowproc (possibly by subclassing if it's not your window)? Or is the window in another app? Mark

    Mark Salsbery Microsoft MVP - Visual C++ :java:

    K Offline
    K Offline
    kcynic
    wrote on last edited by
    #21

    oh, Code-o-mat told me that the tray icon not use WM_RBUTTONUP message any more. yes, i used spy++ and found its message should be TB_GETBUTTONINFO message. Im trying to find a way to hook this message or another method to hook the real procedure of such message.

    1 Reply Last reply
    0
    • K kcynic

      ok. i used spy++ and found the tray icon always receives TB_GETBUTTONINFO message. and i googled found someone said i almost couldn't hook that message in its owner window's message loop, because TB_GETBUTTONINFO is internal messages in controls. right? If so, maybe i only can hook its owner window's main message callback procedure. any idea?

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #22

      I'm not sure but i think you misunderstood something, what i meant is the message that is received by the application if the tray icon is clicked. Usually this works something like: -the application uses Shell_NotifyIcon[^] to install an icon on the tray, specifying -for example- WM_USER or WM_APP or some other message it wants to receive when the icon is clicked on -the user right-clicks the icon on the tray, the application receives the message it specified when using Shell_NotifyIcon along with some other information telling it that the icon was right-clicked (you can look this up in the documentatin if you like), the message is targeted at the window that was also specified when Shell_NotifyIcon was used. -the application displays the popup menu at the mouse cursor's position and handles the user's menu selection So basicly, i gess what you want is to catch the message fed to Shell_NotifyIcon.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. <

      1 Reply Last reply
      0
      • K kcynic

        yes, target_process_id do be defined in a shared segment:

        #pragma data_seg (".SHARED")
        HHOOK g_hPreviousMouseHook = 0;
        HHOOK g_hPreviousWinProcHook = 0;
        HINSTANCE g_hInstance = 0;
        HWND g_hMinimizedWindowList[ARRAY_SIZE] = {0};
        int g_iMinimizedWindowCount = 0;
        DWORD target_process_id = 0;
        #pragma data_seg()

        #pragma comment(linker, "/SECTION:.SHARED,RWS")

        Malli_S, this code slice is copied from your tutor article http://www.codeproject.com/KB/system/TrayMe.aspx. Im trying your demo project today.

        M Offline
        M Offline
        Malli_S
        wrote on last edited by
        #23

        You through with your issue ? [Delegates]      [Virtual Desktop]      [Tray Me !] -Malli...! :rose:

        K 1 Reply Last reply
        0
        • M Malli_S

          You through with your issue ? [Delegates]      [Virtual Desktop]      [Tray Me !] -Malli...! :rose:

          K Offline
          K Offline
          kcynic
          wrote on last edited by
          #24

          yes. I wanna make the target program do nothing when the user click its right mouse key on the tray icon.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups