当前位置: 移动技术网 > IT编程>开发语言>Delphi > 鼠标左键长按功能的实现

鼠标左键长按功能的实现

2019年05月29日  | 移动技术网IT编程  | 我要评论

1、添加[additional]页下的[tapplicationevents]控件

2、申请全局的integer变量,用来计算延时,如:ysnum: integer;

3、在applicationevents1的onmessage事件中,对捕获的wm_lbuttondown消息进行处理

procedure tform1.applicationevents1message(var msg: tagmsg;
  var handled: boolean);

begin

  case msg.message of
    wm_lbuttondown: begin
                                         ysnum:= gettickcount;
                                         end;

  end;
end;

4、然后在相应控件的onmouseup事件中进行延时处理

……

begin

{$warnings off}  //使用gettickcount函数,编译时会产生一个warnins的提示,在此可将warnings开关关闭
if gettickcount - ysnum > 500 then    //此处500为延时500ms
begin

    //==========在此处填写你自己的代码==========
end;
{$warnings on}

end;

5、如果控件没有onmouseup事件,可在第3步中的onmessage事件中对wm_lbuttonup消息进行处理即可

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网