Click to See Complete Forum and Search --> : Diff b/w MouseProc & LowLevelMouseProc
leojose
December 7th, 2005, 03:33 AM
Hi all,
What is the diffrence between the two call back functions MouseProc and LowLevelMouseProc ?
My understanding is that LowLevelMouseProc will monitor 'every' mouse event.But there is some restrictions in the events that MouseProc will respond to, but I don't understand what those limitations are.
Could somebody please throw some light on this.
Thanks
humptydumpty
December 7th, 2005, 03:58 AM
According to MSDN
The LowLevelMouseProc hook procedure is an application-defined or library-defined callback
function used with the SetWindowsHookEx function. The system call this function every time
a new mouse input event is about to be posted into a thread input queue. The mouse input
can come from the local mouse driver or from calls to the mouse_event function. If the input
comes from a call to mouse_event, the input was "injected". However, the WH_MOUSE_LL
hook is not injected into another process. Instead, the context switches back to the
process that installed the hook and it is called in its original context. Then the context
switches back to the application that generated the event.
The HOOKPROC type defines a pointer to this callback function. LowLevelMouseProc is a
placeholder for the application-defined or library-defined function name.
LRESULT CALLBACK LowLevelMouseProc( int nCode,
WPARAM wParam,
LPARAM lParam
);
Mouse Proc
The MouseProc hook procedure is an application-defined or library-defined callback function
used with the SetWindowsHookEx function. The system calls this function whenever an
application calls the GetMessage or PeekMessage function and there is a mouse message
to be processed.
The HOOKPROC type defines a pointer to this callback function. MouseProc is a placeholder
for the application-defined or library-defined function name.
LRESULT CALLBACK MouseProc( int nCode,
WPARAM wParam,
LPARAM lParam
);
leojose
December 7th, 2005, 04:06 AM
WM_MOUSE_LL
The system call this function every time a new mouse input event is about to be posted into a thread input queue.The mouse input can come from the local mouse driver or from calls to the mouse_event function.
V/s
WM_MOUSE
The system calls this function whenever an application calls the GetMessage or PeekMessage function and there is a mouse message to be processed.
So what exactly makes them different? When must I call one or the other? Is WM_MOUSE_LL a kind of 'global hook' and WM_MOUSE not?
golanshahar
December 7th, 2005, 04:36 AM
So what exactly makes them different?
ok lets start with the fact that WM_MOUSE_LL is only available in NT and higher you cant use it under windows 98.
another difference between the two is that the WM_MOUSE_LL is low level one ( by definition ;) ) you will get the callback for the mouse input each time a mouse input has occurred.
when using the WM_MOUSE, the callback will be called only after an application will call ::GetMessage() or ::PeekMessage(), so it basically depend on the message pump of the window.
further more you can see difference in the parameters you are getting in each callback for instance when using the WM_MOUSE you have the hwnd in the MOUSEHOOKSTRUCT, something you wont have in the WM_MOUSE_LL.
When must I call one or the other? Is WM_MOUSE_LL a kind of 'global hook' and WM_MOUSE not?
now that depends on what exactly you need....and what are your requirements. ;)
Cheers
leojose
December 7th, 2005, 04:49 AM
when using the WM_MOUSE, the callback will be called only after an application will call ::GetMessage() or ::PeekMessage(), so it basically depend on the message pump of the window.
further more you can see difference in the parameters you are getting in each callback for instance when using the WM_MOUSE you have the hwnd in the MOUSEHOOKSTRUCT, something you wont have in the WM_MOUSE_LL.
So...if I want to hook the mouse events of a particular window only, I can pass its hwnd and use the WM_MOUSE. whereas WM_MOUSE_LL will hook every possible mouse event.
now that depends on what exactly you need....and what are your requirements. ;)
I would like my hook to capture every mouse event, but at the same time it should also work on all Windows OSs. So would you recommend using WM_MOUSE_LL for all OSs and WM_MOUSE for win98?
Does WM_MOUSE work as effectively as WM_MOUSE_LL when it comes to capturing all mouse events (maybe by passing NULL as hwnd or something like that)?
golanshahar
December 7th, 2005, 05:48 AM
So...if I want to hook the mouse events of a particular window only, I can pass its hwnd and use the WM_MOUSE. whereas WM_MOUSE_LL will hook every possible mouse event.
yes you can do it, but agian you wont have the HWND if you using the WM_MOUSE_LL, but of course you can use ::WindowFromPoint(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/windowfrompoint.asp) api to get the hwnd in the point you getting from the WM_MOUSE_LL hook.
I would like my hook to capture every mouse event, but at the same time it should also work on all Windows OSs. So would you recommend using WM_MOUSE_LL for all OSs and WM_MOUSE for win98?
if you need it also for WIN98 then i think it is better to use WM_MOUSE instead of WM_MOUSE_LL.
Does WM_MOUSE work as effectively as WM_MOUSE_LL when it comes to capturing all mouse events (maybe by passing NULL as hwnd or something like that)?
well again in both hooks you will get the mouse events the main difference is when your mouse callback will be called.
go for WM_MOUSE it will be enough for you. ;)
Cheers
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.