IGxRect.Contains

Syntax

Contains(X: Integer, Y: Integer): Boolean;

Contains(X: integer, Y: integer): boolean;

Parameters

X. The X coordinate of the point.

Y. The Y coordinate of the point.

Description

The Contains method checks if the integer rectangle contains the point.

Comments

Available method values:

Example

Executing the example requires:

Add links to the Drawing, Forms, MathFin, Report, Tab, UI system assemblies.

The example is a handler of the OnClick event for the Button1 component.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Obj: ITabObject;
    Tab: ITabSheet;
    Rect: IGxRect;
    X, Y: Integer;
Begin
    
// Create a new rectangle with specified sizes
    Rect := New GxRect.Create(005045);
    Tab := UiTabSheet1.TabSheet;
    
// Add an image to the created rectangle
    Obj := Tab.Objects.Add("PrxPicture", Rect.ToRectF);
   (Obj 
As IPrxPicture).Image := GxImage.FromFile("c:\1.bmp");
   
// Set point with random coordinates
    X := Math.RandBetweenI(070);
    Y := Math.RandBetweenI(
070);
    
// Check that point enters to the rectangle
    If Rect.Contains(X, Y) Then
        WinApplication.InformationBox(
"Yes");
    
Else
        WinApplication.InformationBox(
"No");
End If;
End Sub Button1OnClick;

Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.MathFin;
Imports Prognoz.Platform.Interop.Forms;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Tab;
Imports Prognoz.Platform.Interop.Ui;

Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    Obj: ITabObject;
    Tab: ITabSheet;
    Rect: GxRect = 
New GxRectClass();
    S: string;
    X, Y: integer;
    Math: MathClass = 
New MathClass();
    Image: GxImageClass_2 = 
New GxImageClass_2();
    WinAppCls: WinApplicationClass = 
New WinApplicationClassClass();
Begin
    
// Create a new rectangle with specified sizes
    Rect.Create(005045);
    Tab := UiTabSheetNet1.TabSheetUi.TabSheet;
    
// Add an image to the created rectangle
    Obj := Tab.Objects.Add("PrxPicture", Rect.ToRectF());
    Image.CreateFromFile(
"c:\1.bmp");
   (Obj 
As IPrxPicture).Image := Image;
    
// Set point with random coordinates
    X := Math.RandBetweenI(070);
    Y := Math.RandBetweenI(
070);
    
// Check that point enters to the rectangle
    If Rect.Contains(X, Y) Then
        WinAppCls.InformationBox(
"Yes"New IWin32WindowForeAdapter(Self));
    
Else
        WinAppCls.InformationBox(
"No"New IWin32WindowForeAdapter(Self));
End If;
End Sub;

After executing the example clicking the Button1 button creates an image in the regular report. The image source is the 1.bmp file. The information window contains Yes if the point with the random coordinates is included to the rectangle that bounds the image.

See also:

IGxRect