1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| HHOOK MouseHookHandle;
BOOL CIHMListeDlg::OnInitDialog()
{
CString s1;
CDialog::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
}
//////////////////////////////////////////////////////////////////////////////////////
static 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);
} |