A (nasty) platform specific method would be to install either a low level Win32 mouse event hook or a normal mouse event hook. As far as I know, the low level hooks don’t work with all versions of windows >=95, but the normal mouse hooks should do.
You can use SetWindowsHookEx(…) to install a hook procedure that gets messages before they even get sent to the windows. The following code is just off the top of my head, so it probably will not compile if you cut and paste, but then again it may do if your lucky :-).
glob_myHook=SetWindowsHookEx( WH_MOUSE, //install simple mouse hook
myHookProc, //the hook procedure
GetModuleHandle(NULL), //get the instance handle for this thread/program
0); //install for all threads, you may want to read the docs about this.
if(glob_myHook==NULL) return false; return true;
LRESULT myHookProc(int nCode, WPARAM wParam, LPARAM lParam)
//nCode, contains info about the mouse event //wParam is message ID //lParam is a MOUSEHOOKSTRUCT //MOUSEHOOKSTRUCT contains info on co-ords etc etc //you can change the values here, then pass the message on if //you need to. //do something with the message //call next proc in the chain. return CallNextHookEx(glob_myHook, nCode, wParam, lParam);
See the following for more info:
Of course you should probably remove the hook before your app quits, just so it plays nice with the rest of Windows;
Hope this helps,