如何屏蔽鼠标按键

uncarman 2002-11-20 09:27:28
在应用程序中如何屏蔽鼠标按键,用delphi实现,请高手指点
...全文
83 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
uncarman 2002-12-01
  • 打赏
  • 举报
回复
我用另外一种钩子类型搞定了。尽管你们没有回答准确,我还是非常感谢,散分!
uncarman 2002-11-28
  • 打赏
  • 举报
回复
加到100,请高手相助
蝈蝈太阳 2002-11-26
  • 打赏
  • 举报
回复
UP
uncarman 2002-11-22
  • 打赏
  • 举报
回复
stanely,你好,用了你的方法在win2000下无法屏蔽鼠标按键,是否是键盘虚拟码(wparam这个参数值不对),请解答。
stanely 2002-11-21
  • 打赏
  • 举报
回复
在鼠标钩子响应函数里面让result:=-1就可以!最有效!

hhk:=setwindowshookex(wh_mouse,@hookproc,hinstance,0);

这句执行的地方如果在dll里就是操作系统的鼠标钩子,让所有的鼠标点击都失效,如果在exe里面,只是本进程内鼠标点击失效。

function hookproc(ncode:smallint;wparam,lparam:integer):integer;
begin
result:=-1;
if ncode<0 then
result:=callnexthookex(hhk,ncode,wparam,lparam);
end;
stanely 2002-11-21
  • 打赏
  • 举报
回复
屏蔽右键也简单,
function hookproc(ncode:smallint;wparam,lparam:integer):integer;
begin
if wparam=$0204 then//按了右键。
result:=-1
else
result:=0;
if ncode<0 then
result:=callnexthookex(hhk,ncode,wparam,lparam);
end;

uncarman 2002-11-21
  • 打赏
  • 举报
回复
我要单单屏蔽鼠标右键,而不是所有按键。
必须用鼠标钩子实现,请指点。
vickeen 2002-11-20
  • 打赏
  • 举报
回复
不过鼠标的Hook好象比较难。
vickeen 2002-11-20
  • 打赏
  • 举报
回复
用钩子Hook,可能挂接wh_getmessage钩子比较好。
vickeen 2002-11-20
  • 打赏
  • 举报
回复
比较简单的办法是,响应Delphi的OnMouseDown事件,其定义如下:
type
TMouseEvent = procedure (Sender: TObject; Button: TMouseButton;  
        Shift: TShiftState; X, Y: Integer) of object;
property OnMouseDown: TMouseEvent;
而TMouseButton的定义是这样的:
type TMouseButton = (mbLeft, mbRight, mbMiddle);
当探测到TMouseButton为mbRight,不执行任何语句,既可。
其实这种方法还可以屏蔽鼠标左键和中键,详细情况见Delphi的帮助

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧