Updated: Dec 16, 2023
Follow on twitter

Showing in the TsMagnifier component of scaled content under mouse cursor, moving a magnifier window.

The TsMagnifier component has the OnGetSourceCoords event. This event allows to define coordinations of a source image rectangle. Example of code for handling this event:

uses sConst; ... procedure TMainForm.sMagnifier1GetSourceCoords(var ATopLeft: TPoint); begin ATopLeft := acMousePos; // Current coords of mouse cursor if Assigned(acMagnForm) then begin // If magnifier window is created dec(ATopLeft.X, acMagnForm.Width div (sMagnifier1.Scaling * 2)); // Offset a position dec(ATopLeft.Y, acMagnForm.Height div (sMagnifier1.Scaling * 2)); end; end;

sConst.acMagnForm variable is a magnifier form. Developer can change coordinates of this window if it's needed after showing or take some other actions. But, don't forget to check that window is not nil.






Installing, using and licensing the demo programs © Sergii Goncharov, Ukraine, Odessa 2004-2023