DelphiVCL.Rect or TRect defines a rectangle.
TRect represents the dimensions of a rectangle. The coordinates are specified as either four separate integers representing the left, top, right, and bottom sides, or as two points representing the locations of the upper-left and lower-right corners.
Typically, DelphiVCL.Rect values represent pixel locations, where the origin of the pixel coordinate system is in the upper-left corner of the screen (screen coordinates) or the upper-left corner of a control’s client area (client coordinates). When a TRect value represents a rectangle on the screen, by convention the top and left edges are considered inside the rectangle and the bottom and right edges are considered outside the rectangle. This convention allows the width of the rectangle to be Right – Left and the height to be Bottom – Top.
Let’s browse all the properties, methods, and built-in properties of the DelphiVCL.Rect using dir() command:
1 2 3 |
import DelphiVCL dir(DelphiVCL.Rect) |
See the responses in our Windows command prompt:
You can also read short information about theDelphiVCL.Rect using the print() command:
1 2 |
print(DelphiVCL.Rect) print(DelphiVCL.Rect.__doc__) |
See the responses in our Windows command prompt:
Here is the working example of the implementation of Rect:
1 2 3 4 5 6 7 8 9 10 11 |
def grdTestDrawCell(Sender, Col, Row, Rect, State): if gdSelected in State: Sender.Canvas.Brush.Color = clBlue # 0x00ff0000 # blue Sender.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, "%d @ %d" % (Col, Row)) def grdTestSelectCell(Sender, Col, Row, CanSelect): if Col == 2 and Row == 2: CanSelect.Value = False grdTest.OnDrawCell = grdTestDrawCell grdTest.OnSelectCell = grdTestSelectCell |
See the complete code here.
The result:
Check out DelphiVCL which easily allows you to build GUIs for Windows using Python.