3

Good morning all.

I have a question about handle of TRichEdit.

In a TRichEdit I have a text with several riched formats (Bold, Italic, Underline) like this:

RTF Text

Can I have the possibility of know the style of each character in the Edit, for instance, the first 's' has no format, the first 'r' has a bold format, the second 'a' has italic format, and the fourth 'a' has underline format?

The purpose of this question is for convert this text to HTML tags. I tried many functions on Internet and no one works for me.

I appreciate your help so much.

  • Have you tried opening your .rtf file in notepad and examining it that way? – Hugh Jones Mar 16 '16 at 15:19
  • You might also want to try saving the rtf as html and seeing what that outputs – Hugh Jones Mar 16 '16 at 15:22
  • 1
    It will be very slow if you operate character by character. But yes you can iterate over each character with `SelStart` and `SelLength`. Then you read `SelAttributes` IIRC. – David Heffernan Mar 16 '16 at 15:27
  • @David - I did that once many years ago - it was a very painful process – Hugh Jones Mar 16 '16 at 15:42
  • Is it your intention to convert the contents of a rich edit to HTML? Or to convert rich text format to HTML? Because if it's the latter, you shouldn't bother using a rich edit control at all, but read the raw RTF format. – Jerry Dodge Mar 16 '16 at 16:07
  • 1
    http://stackoverflow.com/questions/11954946/how-to-convert-simple-richtext-to-html-tags-in-delphi -> https://www.habarisoft.com/scroogexhtml_delphi.html – fantaghirocco Mar 17 '16 at 15:26

0 Answers0