1

I need to align paragraph vertically (top, center, bottom) in a RichEdit.

I googled it and found nothing about this issue. Does anybody know a workaround

to achive this. I use C++ Builder 2010, are there any VCL or Windows API way solution?

neutron
  • 11
  • 2

1 Answers1

1

I don't think TRichEdit supports Vertical Text Alignment. For example take this tiny RTF document:

{\rtf1\ansi\ansicpg1250\deff0\deflang1048{\fonttbl{\f0\fnil\fcharset0 Calibri;}}\viewkind4\uc1\pard\sa200\sl276\slmult1\qc\lang9\f0\fs22\vertalc Text\par}

When this is put into TRichEdit the "Text" is only aligned horizontally. Open the document with WordPad and it looks absolutely the same. Open it up with Ms Word and the "Text" is centered both vertically and horizontally in the page. Since TRichEdit doesn't support the \vertalc, there's no need for any kind of API to set that attribute.

Cosmin Prund
  • 25,498
  • 2
  • 60
  • 104
  • @Cosmin Prund thanks for you rapid answer, TRichEdit does'nt support this but what about standart windows RichEdit controls? – neutron Jun 14 '11 at 07:57
  • 1
    TRichEdit is nothing but a wrapper around the Windows-provided RichEdit control. When you load that tiny bit of RTF into TRichEdit, all it does is pass it to the standard RichEdit control. WordPad is also a wrapper around the same standard RichEdit control. If WordPad showed the text vertically aligned, or loading that RTF into TRichEdit showed it vertically aligned it would be proof the standard RichEdit control supports it and we'd be looking for hacks to use the functionality from `TRichControl`. – Cosmin Prund Jun 14 '11 at 08:05
  • so you mean MS Word uses something different than Windows-provided RichEdit? – neutron Jun 14 '11 at 08:16
  • Yes, Word has a much more complex component to display text. The Windows RichEdit can also not display any images or OLE-objects. – Andreas Jun 14 '11 at 08:19
  • You may use an alternative as editor. You can access MS-Word or OpenOffice over COM-interface or there are a few commercial VCL-components. – Andreas Jun 14 '11 at 08:20
  • @neutron, of course Word uses a different editor! Ask the question the other way around: Do you expect *full* MsWord functionality in a *free* editor? – Cosmin Prund Jun 14 '11 at 08:43
  • @Andreas do you have any advice for commercial components? – neutron Jun 14 '11 at 08:49
  • @Cosmin Prund Actually i don't really expect full features of MSWord but i thought it would be possible to implement vertical alignment functionality on standart richedit control by some workaround. – neutron Jun 14 '11 at 08:54