How to limit the mouse movement area in Delphi.

zhaozj2021-02-17  46

The following is limited to the mouse mobile region (100, 100, 200, 200)

Var reference: TRECT;

Begin

Rect.Left: = 100;

Rect.top:=100;

Rect.bottom: = 200;

RECT.right: = 200;

Windows.clipcursor (@Rect);

The move area of ​​the mouse is restored below

Windows.clipcursor (0);

The specific list is not used, it is very simple. he he he he he

Help in Delphi is written like this:

The clipcursor function confines The Cursor to a Rectangular Area on the screen.

IF a subsequent cursor position (set by the setcursorpos function or the mouse)

LIES OUTSIDE THE Rectangle, Windows Automatical Adjusts The position to keep the

Cursor Inside The Rectangular Area.

Bool Clipcursor

Const Rect * LPRECT / / POINTER TO STRUCTURE WITH Rectangle

);

Parameters

Lprc

Points to the Rect Structure That Contains The Screen Coordinates of the Upper-

Left and lower-right corners of the confining rectangle. if this parameter is

Null, The Cursor is Free to Move Anywhere on The Screen.

Return Values

IF The Function Succeeds, The Return Value IS Nonzero.

If the function fails, the return value is zero. TO GET Extended Error Information, Call getLastError.

Remarks

The cursor is a shared resource. If an application confines the cursor, it must

Release the cursor by using clipcursor before relinquishing control to another

APPLICATION.

The Calling Process Must Have Winsta_WriteAttributes Access To The Window Station.

转载请注明原文地址:https://www.9cbs.com/read-28368.html

New Post(0)