salut a tous,
je vien d'implementer un hook pour intercepter tout les evenements souris de mon application. pour cela j'ai utiliser la faq et la msdn et j'arrive a ceci:
.h:
1 2 3
|
HHOOK MouseHookHandle;
LRESULT CALLBACK MouseProc(int nCode,WPARAM wParam,LPARAM lParam); |
.cpp:
dans OnInitDialog:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| BOOL CIHMListeDlg::OnInitDialog()
{
.......
MouseHookHandle = SetWindowsHookEx(WH_MOUSE,
(HOOKPROC)MouseProc,
(HINSTANCE) NULL,
GetCurrentThreadId());
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
} |
et le contenu de ma fonction du hook:
1 2 3 4 5 6 7
| LRESULT CALLBACK MouseProc(int nCode,WPARAM wParam,LPARAM lParam)
{
// On joue un son à chaque fois que l'utilisateur enfonce le bouton gauche
if (wParam == WM_LBUTTONDOWN)
MessageBeep(MB_OK);
return CallNextHookEx(MouseHookHandle,nCode,wParam,lParam);
} |
seulement j'obtien deux erreurs:
error C2440: 'type cast' : cannot convert from '' to 'long (__stdcall *)(int,unsigned int,long)'
qui pointe vers l'appel de SetWindowsHookEx() et plus particulierment sur et
error C2065: 'MouseHookHandle' : undeclared identifier
qui pointe sur
return CallNextHookEx(MouseHookHandle,nCode,wParam,lParam);
je ne comprend pas, quesqu'y cloche???
Partager