我想要鼠标禁止移动一段时间,然后再恢复移动,请高手指教

解决方案 »

  1.   

    我想在一个函数中实现如下流程:
      begin
      鼠标禁止
       处理事务
      鼠标恢复
     end;
    情况紧急,马上给分。
      

  2.   

    在onmousemove事件写
    x:=1;
    y:=1;
    固定一点
      

  3.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    var
      posRect : TRect;  //锁定的范围
    begin
      posRect.TopLeft := point(0,0);
      posRect.BottomRight := point(1,1);
      ClipCursor(@posRect);
      Cursor := crNone;
    end;//通过设置Timer.Enabled确定锁定
    //解锁ClipCursor(nil);
      

  4.   

    procedure EnableMouse(Enabled: Boolean);
    var
      R: TRect;
      p: TPoint;
    begin
      if Enabled then
        ClipCursor(nil)
      else begin
        GetCursorPos(p);
        R := Rect(p.X, p.Y, p.X, p.Y);
        ClipCursor(@R);
      end;
    end;begin
      EnableMouse(False);
       处理事务
      EnableMouse(True);
    end
      

  5.   

    在timmer中设置要禁止的时间
    要鼠标禁止移动调用 EnableMouse(false)
    计时全局变量timecount:=0
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      if timecount>=(一段时间) then
        EnableMouse(true)
      else
        timecount:=timecount+(时间);
    end;procedure EnableMouse(Enabled: Boolean);
    var
      R: TRect;
      p: TPoint;
    begin
      if Enabled then
        ClipCursor(nil)
      else begin
        GetCursorPos(p);
        R := Rect(p.X, p.Y, p.X, p.Y);
        ClipCursor(@R);
      end;
    end;