I wrote a mouse hook function on app, but it only work when our program was
activing, if i focused on another app, then my hook function didn't work
more.
Any problem? I must write this function in a dll? So it can work on whole
system?
BOOL CMouseLightDlg::StartMouseHook()
{
DWORD dwHookType;
HOOKPROC hProc;
dwHookType = WH_MOUSE;
hProc = (HOOKPROC) MouseProc;
g_hhMouseHook = SetWindowsHookEx(dwHookType,
hProc,
AfxGetApp()->m_hInstance,
0 );
if( g_hhMouseHook == NULL || GetLastError() != 0 )
return FALSE;
return TRUE;
}
"James Duy Trinh" <viet...@gmail.com> wrote in message
news:u2EhwP8$IHA....@TK2MSFTNGP04.phx.gbl...
Of course.
Read MSDN : everything is explained, with complete samples
Your hook needs to be in a DLL, which will be loaded into all processes.
Otherwise the hook will only work for your process.
g_hhMouseHook needs to be declared in shared data segment so that your hook
proc can access it no matter which process it is in.
-- David
"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:GgJpk.34688$co7....@nlpi066.nbdc.sbc.com...
"david" <da...@nospam.com> wrote in message
news:ujpagl8$IHA....@TK2MSFTNGP05.phx.gbl...
Some hooks don't need to be in a DL, like WH_MOUSE_LL. But WH_MOUSE does
need to be in a DLL.
-- David
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
But i have a problem how to use get Delta info of WM_MOUSEWHEEL
In LRESULT CALLBACK HookProc(int ncode, WPARAM wparam, LPARAM lparam)
wparam is equal to MOUSEWHEEL
lparam can't get delta info.
Can you help me?
"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
news:k22fa4hqjc5l9hguj...@4ax.com...
If WH_GETMESSAGE, then the LPARAM is actually an (LPARAM)(LPMSG) and the LPMSG is the same
LPMSG that would appear for the GetMessage call, so
LPMSG msg = (LPMSG)lParam;
delta = HIWORD(msg->wParam);
should give you the delta.
joe