ImageEn, unit imageenview
TImageEnView.AutoScrollTowardCursor
Declaration function AutoScrollTowardCursor(ScrollInterval: Integer = 200): Boolean; Description
If the cursor is outside the area of the control, the image view will be slowly scrolled in that direction, e.g. moving to the right of the control, will scroll the image right.
This can be used in your MouseMove code to allow the user to scroll the content to perform a custom selection, for example.
ScrollInterval specifies the delay between scroll movements.
Result will be true if a scroll occurs.
// Example code to draw a custom selection rectangle and auto-scroll when the user moves the cursor outside the control area procedure TForm1.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin fMyCustomSelectionActive := True; fMyCustomSelectionStart.X := ImageEnView1.XScr2Bmp(X, False); fMyCustomSelectionStart.Y := ImageEnView1.YScr2Bmp(Y, False); end; procedure TForm1.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if fMyCustomSelectionActive then begin ImageEnView1.AutoScrollTowardCursor(); fMyCustomSelectionCurr.X := ImageEnView1.XScr2Bmp(X, False); fMyCustomSelectionCurr.Y := ImageEnView1.YScr2Bmp(Y, False); ImageEnView1.Invalidate(); end; end; procedure TForm1.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin fMyCustomSelectionActive := False; end; procedure TForm1.ImageEnView1DrawCanvas(Sender: TObject; ACanvas: TCanvas; ARect: TRect); var scrRect: TRect; begin if fMyCustomSelectionActive then begin scrRect.Left := ImageEnView1.XBmp2Scr( fMyCustomSelectionStart.X ); scrRect.Top := ImageEnView1.YBmp2Scr( fMyCustomSelectionStart.Y ); scrRect.Right := ImageEnView1.XBmp2Scr( fMyCustomSelectionCurr.X ); scrRect.Bottom := ImageEnView1.YBmp2Scr( fMyCustomSelectionCurr.Y ); ACanvas.Brush.Style := bsClear; ACanvas.Pen.Width := 3; ACanvas.Pen.Style := psSolid; ACanvas.Pen.Mode := pmNot; ACanvas.Rectangle( scrRect.Left, scrRect.Top, scrRect.Right, scrRect.Bottom); end; end;
Loading contents...