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
在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;
begin
鼠标禁止
处理事务
鼠标恢复
end;
情况紧急,马上给分。
x:=1;
y:=1;
固定一点
var
posRect : TRect; //锁定的范围
begin
posRect.TopLeft := point(0,0);
posRect.BottomRight := point(1,1);
ClipCursor(@posRect);
Cursor := crNone;
end;//通过设置Timer.Enabled确定锁定
//解锁ClipCursor(nil);
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
要鼠标禁止移动调用 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;