Intercept all mouse event for a specified hwnd
-
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:
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.
-
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?
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. <
-
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.