MFC一定条件后开启HOOK屏蔽鼠标信息的方法

如题。因为刚刚接触HOOK,所以不知道如何能设定这个条件
2024-12-01 20:16:19
推荐回答(1个)
回答1:

什么叫屏蔽鼠标信息呢? 屏蔽鼠标消息?


用级低鼠标钩子:

HHOOK g_LowLevelMouseHook=NULL;	//钩子句柄
LRESULT CALLBACK LowLevelMouseProc(int nCode,WPARAM wParam, LPARAM lParam)

if (nCode<0 )
return CallNextHookEx(g_LowLevelMouseHook,nCode,wParam,lParam);

POINT point=((MSLLHOOKSTRUCT*)lParam)->pt;

switch (wParam)
{
case WM_MOUSEMOVE:
{

}
break;


case WM_RBUTTONDOWN:
{
trace("WM_RBUTTONDOWN");
return 1; //屏蔽此消息
}
break;
}
return CallNextHookEx(g_LowLevelMouseHook,nCode,wParam,lParam); //传递钩子信息
}


// 启动钩子
g_LowLevelMouseHook=SetWindowsHookEx(WH_MOUSE_LL,LowLevelMouseProc,GetModuleHandle(NULL),0);