redirecting mouse button ??
-
I used SetWindowsHookEx(WH_MOUSE,....) to get mouse message. After get mouse message(like WM_RBUTTONUP...)I need to redirect it. For example, when user clicks right button, I want call 'Run...' dialog. I know that I need to disable popup menu and then to do what I want it to do. Below is my code: HHOOK glhHook = NULL; HINSTANCE glhInstance = NULL; glhook = SetWindowsHookEx(WH_MOUSE, MouseProc, glhInstance, 0); . . . LRESULT WINAPI CALLBACK MouseProc(int nCode, WPARAM wp, LPARAM lp) { if(wp == WM_RBUTTONUP) { // do something.... ((MOUSEHOOKSTRUCT*)lp->hwnd = NULL; ((MOUSEHOOKSTRUCT*)lp->wHitTestCode = NULL; ((MOUSEHOOKSTRUCT*)lp->dwExtraInfo = NULL; return false; } } but it still show the popup menu and ignore the action I want to do why??? Is anybody can give me some suggestion?
-
I used SetWindowsHookEx(WH_MOUSE,....) to get mouse message. After get mouse message(like WM_RBUTTONUP...)I need to redirect it. For example, when user clicks right button, I want call 'Run...' dialog. I know that I need to disable popup menu and then to do what I want it to do. Below is my code: HHOOK glhHook = NULL; HINSTANCE glhInstance = NULL; glhook = SetWindowsHookEx(WH_MOUSE, MouseProc, glhInstance, 0); . . . LRESULT WINAPI CALLBACK MouseProc(int nCode, WPARAM wp, LPARAM lp) { if(wp == WM_RBUTTONUP) { // do something.... ((MOUSEHOOKSTRUCT*)lp->hwnd = NULL; ((MOUSEHOOKSTRUCT*)lp->wHitTestCode = NULL; ((MOUSEHOOKSTRUCT*)lp->dwExtraInfo = NULL; return false; } } but it still show the popup menu and ignore the action I want to do why??? Is anybody can give me some suggestion?
First, make sure that your code is in a DLL, message hook procs need to be placed in a DLL. Second, is your code not being called at all, or it is being called, but what you want to happen is not happening? When you do get your code to happen, you will not want to send the message on to the other hooks in the chain. If you want to prevent whatever app that should receive the mouse message from displaying the context menu, the only way to do this is to make sure that they do not receive the message.
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!