Contains(X: Integer, Y: Integer): Boolean;
X. The X coordinate of the point.
Y. The Y coordinate of the point.
The Contains method checks if the integer rectangle contains the point.
Available values:
True. If the point with X and Y coordinates is contained in integer rectangle.
False. If point with X and Y coordinates is not contained in integer rectangle.
Executing the example requires:
A form with a button with the Button1 identifier, the TabSheetBox and UiTabSheet components with the TabSheetBox1 and UiTabSheet1 corresponding identifiers. For TabSheetBox select the component with the UiTabSheet1 identifier in the Source property.
Bitmap file C:\1.bmp.
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(0, 0, 50, 45);
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(0, 70);
Y := Math.RandBetweenI(0, 70);
// 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;
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: