Solved

Styles in RichEdit

Posted on 1998-05-27
9
383 Views
Last Modified: 2013-11-23
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
Comment
Question by:MickeyE
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 2

Expert Comment

by:rene100
ID: 1348042
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
 

Expert Comment

by:heapster
ID: 1348043
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
 

Author Comment

by:MickeyE
ID: 1348044
I'm sorry I didn't mention that I don't want to use any 3rd party components.
0
 

Expert Comment

by:heapster
ID: 1348045
So presumably you want the rich text format so you can read/write the attributes more quickly?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:MickeyE
ID: 1348046
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
 
LVL 7

Accepted Solution

by:
BlackMan earned 300 total points
ID: 1348047
Hi MickeyE
I've done such a beast, i'll email to you, it's quite large...
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1348048
Hi MickeyE.. I've cut my code down - please reopen the question and i'll post it here
0
 
LVL 3

Expert Comment

by:lopem
ID: 2781583
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
 

Expert Comment

by:Delphiwizard
ID: 12612497
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Memory leak using records in a TVirtualStringTree 11 109
Newbie Thread Programming 1 139
Delphi - replicating a form 8 62
Firemonkey webbrowser scrollbars ? 1 29
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now