How To Center Vertically

General TRichView support forum. Please post your questions here
Post Reply
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

How To Center Vertically

Post by DickBryant »

The application which I am upgrading with TRichView had the ability to center text both horizontally and vertically.

I achieved the vertical centering by loading the text into an invisible TMemo and using TMemo's Lines.Count property to count the lines. I then calculated the number of lines possible in the resizeable window and inserted 1/2 this number of blank lines in front of the text before displaying it in the actual TMemo.

I tried using the obsolete TRV.Lines property, but it doesn't seem to actually return the number of lines - more like the number of items?

Do you have any suggestion on how to achieve vertical centering for a TRichViewEdit (read only)?

Thanks!
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Set RichView.VAlign = tlCenter.

TRichView is not TMemo, lines can be of different height.
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

Post by DickBryant »

That was easy!

Perhaps cross reference the .VAlign property (of TRichView, TRichViewEdit) with the .Style.ParaStyles[0].Alignment property to make it easier to see the relationship between the global vertical centering and the by-paragraph horizontal centering.

It's clear to me NOW why it's that way, but after finding the horizontal centering I didn't think to look at the global level for the vertical control.

Thanks!
Post Reply