Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Mouse wheel and TopWindow
Mouse wheel and TopWindow [message #5746] |
Thu, 12 October 2006 18:04 |
atmks
Messages: 33 Registered: July 2006
|
Member |
|
|
hi all
how can i catch mousewheel event
outside topwindow (platform WinXp)?
pressing of mousebutton is simply with GetAsyncKeyState function,
but mousewheel...
bye
atmks
|
|
|
|
Re: Mouse wheel and TopWindow [message #6712 is a reply to message #5754] |
Fri, 24 November 2006 01:34 |
atmks
Messages: 33 Registered: July 2006
|
Member |
|
|
hi, i finded the solution
i used a dll hook technology:
dll source:
hook.h
#ifndef _hook_hook_h
#define _hook_hook_h
#define DllImport extern "C" __declspec(dllimport)
#define DllExport extern "C" __declspec(dllexport)
#ifdef flagDLL
#define DLLIMPORT __declspec(dllexport)
#else
#define DLLIMPORT __declspec(dllimport)
#endif
void DLLIMPORT SetHooks(HHOOK hk,HWND hwnd);
LRESULT DLLIMPORT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
#endif
hook.cpp
#include <windows.h>
#include <stdio.h>
#include "hook.h"
HHOOK hMouseHook = NULL;
HWND mHwnd = 0;
HWND cur_hwnd = 0;
BOOL APIENTRY DllMain(HANDLE hModule, DWORD reason, LPVOID lpReserved) {
switch (reason) {
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
void DLLIMPORT SetHooks(HHOOK hk,HWND hwnd) {
hMouseHook = hk;
mHwnd = hwnd;
}
LRESULT DLLIMPORT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
HWND hwnd_spion = FindWindow("spion",0);
PostMessage(hwnd_spion,nCode,wParam,lParam);
return CallNextHookEx(hMouseHook,nCode,wParam,lParam);
}
application source
main.cpp:
int WM_MYMOUSEWHEEL;
HMODULE hMod;
HHOOK hHk;
...
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
if(message==WM_MYMOUSEWHEEL) {
//mousewheel event
}
...
}
GUI_APP_MAIN() {
WNDCLASS wndclass ;
...
wndclass.lpszClassName = TEXT("spion") ;
...
hMod = LoadLibrary("hook.dll");
if(hMod == NULL)
LOG("LoadLibrary failed");
hHk = SetWindowsHookEx(14,&MouseProc,hMod,0);
if(hHk == NULL)
LOG("SetWindowsHookEx failed");
SetHooks(hHk,hwnd);
WM_MYMOUSEWHEEL = RegisterWindowMessage("mouse_wheel_rulez");
...
}
|
|
|
Goto Forum:
Current Time: Sun May 05 09:20:16 CEST 2024
Total time taken to generate the page: 0.02300 seconds
|