Declaration procedure:
LockCursorTo procedure (targetHwnd: hWnd);
var
r: TRect;
begin
if targetHwnd <> 0 then
begin
GetWindowRect (targetHwnd, r);
ClipCursor (@ r);
end
ClipCursor else (nil);
end;
Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
begin
LockCursorTo (Button2.Handle);
end;
To restore the cursor function kesediakala, targetHwnd parameter set to 0. example:
procedure TForm1.Button2Click (Sender: TObject);
begin
LockCursorTo (0);
end;
No comments:
Post a Comment