delphi7.
如何使得程序判断鼠标停留在控件上不动的时间是多长?
不胜感激。

解决方案 »

  1.   

    在鼠标悬浮在控件上的事件时取得时间,但其move的事件内取得另一时间,向减即可!
      

  2.   

    借宝地一用(关于鼠标问题)
    软件控制鼠标按下左键5秒钟然后放开,怎么做?
    http://expert.csdn.net/Expert/topic/2658/2658484.xml?temp=.8708155
      

  3.   

    费了我很多工夫,你试试;代码是求鼠标在Button1上停留时间,Timer的InterVal为200:
    var
      bf: Boolean = true;
      s: TDateTime;
      st, et: LongWord;{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
    var
      mp: TPoint;
      ctl: TControl;
    begin
      GetCursorPos(mp);
      mp := ScreenToClient(mp);
      ctl := ControlAtPos(mp, true, true);
      if ctl <> nil then
      begin
        if ctl is TButton then
        begin
          if bf then
          begin
            st := GetTickCount;
            bf := false;
            s := Now();
          end;
          Edit1.Text := FormatDateTime('ss:zzz秒', Now() - s);
        end;
      end
      else
      begin
        if not bf then et := GetTickCount;
        bf := true;
        Edit1.Text := FloatToStr((et - st)/1000) + ' 秒';
      end;
    end;