Delphi Write a String inside a Clipping Rectangle using TextRect

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,203
Credits
4,034
Write a String inside a Clipping Rectangle using TextRect
By Muhammad Azizul Hakim June 2, 2021

We use TextRect to write a string inside a clipping rectangle or within a limited rectangular region. Any portions of the string that fall outside the rectangle passed in the Rect parameter are clipped and don’t appear. The upper left corner of the text is placed at the point (X, Y).

Here is the working example of the implementation of an OnClose event like in the Section 7 (Getting Started with DelphiVCL III: Overview of Commonly used VCL Components):
Python:
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))
1622702994542.png