Delphi - Draw text multiline in the centre of a rect

后端 未结 2 971
余生分开走
余生分开走 2020-12-10 06:20

In Delphi i wish to draw text inside a TRect. I am hoping for the following functionality:

  1. Draw the text centred vertically within the TRect
  2. Draw the
2条回答
  •  一个人的身影
    2020-12-10 06:39

    Measure the text first using DT_CALCRECT. Pass DT_WORDBREAK to specify that word wrapping is enabled. This will allow you to find the required height for your text. Then you can, in your code, calculate the vertical offset that gives you vertically centred text, and draw to that offset.

提交回复
热议问题