How To…Vertically Center Memo Text

Question

“How can I vertically center text in a memo?”

Solution

Report output consists of a collection of Page.DrawCommands[]. Each time the Memo, generates, it creates a DrawCommand that describes the location and content to be rendered. We can use the Memo.OnDrawCommandCreate event to modify the DrawCommand. We can vetically center the wrapped text by inserting some empty lines.

Download:  VeticallyCenterMemoText.zip

Sample Delphi code: