Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

Styles in RichEdit

I have a problem with getting the contens of a RichEdit in a special format.

The problem is very simple:The text property of a richedit gives me the plain text. I need a "StyledText"-property that enables me to get and set the text with special codes for beginning and end of bolded, italiced and underlined text.

If "begin bold" is marked as "<B>" and "end bold" the same, I would have the following "StyledText":

"The word <B>fat<B> is marked bold"

I know it's possible to select some text and check selattributes to see if it's bold and then set the codes accordingly. But its too time consuming to check a lot of text that way.  Offcourse should nesting of codes be possible as in:

"<U>The word <B>fat<B> is marked bold<U>",

where the sentence is underlined.

By the way, I'm using Delphi 3.02...
0
MickeyE
Asked:
MickeyE
  • 2
  • 2
  • 2
  • +3
1 Solution
 
rene100Commented:
hi mickeyE

the only other wea i know is to get the rtf text of the control
(perhaps with exporting it with lines.savetostream) and get the attributes from there
0
 
heapsterCommented:
Trying to get the delphi native richedit component is flogging a bit of a dead horse in my opinion.  I went through months of work trying to sort out a miniature version of Word in a text object and the best solution in the end was to use a third party component - specifically WPtools by Julian Ziersch is the best on the market.  You can use field codes to tag text and set up all the styles you like using tags/invisible markers/field codes.
The native RichEdit component is lacking in so many departments i simply wouldnt recommend using it.
0
 
MickeyEAuthor Commented:
I'm sorry I didn't mention that I don't want to use any 3rd party components.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
heapsterCommented:
So presumably you want the rich text format so you can read/write the attributes more quickly?
0
 
MickeyEAuthor Commented:
Yes... This "StyledText" property I mention.

I thing that rene100 is right about using the SaveToStream-functionality and write a TConversion-descendant class, that handles the conversion from rtf to "StyledText".... The Delphi documentation is very weak regarding writing such a class. Anyway I'm not really interested in saving the text, just getting it.

I will check this out soon, I just haven't had the time to do it.
0
 
BlackManCommented:
Hi MickeyE
I've done such a beast, i'll email to you, it's quite large...
0
 
BlackManCommented:
Hi MickeyE.. I've cut my code down - please reopen the question and i'll post it here
0
 
lopemCommented:
Hi BlackMan,

I can't find the code of the styledtext question. Can you send me the code to my account or post it in the expert section?  Thanks a lot in advance.

Manuel López (lopem)
0
 
Stef MerlijnDeveloperCommented:
Blackman or MickeyE, can you sent me the code for the styles in richedit too?

Would be of great help to me.

Thanks, Stef
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now