IsPtInRgn (Main Control) example for Delphi
Code the LEAD Control MouseDown event as follows:
procedure TForm1.Lead1MouseDown (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
ZoomFactorX: Single; {Used for translating positioning information}
ZoomFactorY: Single; {Used for translating positioning information}
tX,tY :integer; {For translated Mouse coordinates }
begin
ZoomFactorX := Lead1.DstWidth / Lead1.SrcWidth;
ZoomFactorY := Lead1.DstHeight / Lead1.SrcHeight;
{Translate the client coordinates to bitmap coordinates. }
tX := Round((X / ZoomFactorX) - (Lead1.DstLeft / ZoomFactorX) + Lead1.SrcLeft);
tY := Round((Y / ZoomFactorY) - (Lead1.DstTop / ZoomFactorY) + Lead1.SrcTop);
if Lead1.HasRgn and Lead1.IsPtInRgn( tY , tX ) then
Edit1.Text := 'Inside the Region'
else
Edit1.Text := 'Outside the Region';
end;