// The most common use of the cursor is to show a delay // using the hour glass: Screen.Cursor := crHourGlass; TRY FINALLY Screen.Cursor := crDefault END; // Instead of TRY..FINALLY when using the mouse, set the cursor on MouseDown and // reset it on MouseUp. procedure TFormLineStretch.ImageAreaMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin Screen.Cursor := crCross; RestrictCursorToDrawingArea(ImageArea) // see below end; procedure TFormLineStretch.ImageAreaMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin Screen.Cursor := crDefault; RemoveCursorRestrictions // see below end; // Restrict cursor to given rectangular area of a TImage. This is convenient // while drawing on a canvas since leaving the drawing area can cause // problems with some algorithms (e.g., dragging something off the screen // to an area where the user will never find it!) PROCEDURE RestrictCursorToDrawingArea (CONST Image: TImage); VAR CursorClipArea: TRect; BEGIN CursorClipArea := Bounds(Image.ClientOrigin.X, Image.ClientOrigin.Y, Image.Width, Image.Height); Windows.ClipCursor(@CursorClipArea) END {RestrictCursorToDrawingArea}; PROCEDURE RemoveCursorRestrictions; BEGIN Windows.ClipCursor(NIL) END {RemoveCursorRestrictions};