IsPtInRgn (Main Control) example for C++ Builder

Code the LEAD Control MouseDown event as follows:

void __fastcall TForm1::Lead1MouseDown (TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
   float ZoomFactorX; /*Used for translating positioning information */
   float ZoomFactorY; /*Used for translating positioning information */
   int tX,tY ; /*For translated Mouse coordinates */

   ZoomFactorX = Lead1->DstWidth / (float)Lead1->SrcWidth;
   ZoomFactorY = Lead1->DstHeight / (float)Lead1->SrcHeight;

   /*Translate the client coordinates to bitmap coordinates. */
   tX = (X / ZoomFactorX) - (Lead1->DstLeft / ZoomFactorX) + Lead1->SrcLeft;
   tY = (Y / ZoomFactorY) - (Lead1->DstTop / ZoomFactorY) + Lead1->SrcTop;

   if( Lead1->HasRgn && Lead1->IsPtInRgn( tY , tX ))
      Edit1->Text = "Inside the Region";
   else
      Edit1->Text = "Outside the Region";
}