用户登录
用户注册

分享至

鼠标左键长按功能的实现

  • 作者: 阿灿99878251
  • 来源: 51数据库
  • 2021-06-24

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消息进行处理即可

 

软件
前端设计
程序设计
Java相关