Usage of Headings (styles) in a TDBRichEdit.

Hi,

Can anybody tell me how to implement the usage of Headings (styles) in a TDBRichEdit.
(I don't mean headers and footers)

Heading 1 (=Font Arial size 12)
Heading 2 (=Font Arial size 10)

Thanks, please supply code.
Stef
Stef MerlijnDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

esoftbgCommented:
You may develop for yourself a DB-Rich-Editor ....
0
kretzschmarCommented:
TDBRichEdit nor TRichedit do not support Styles like Winword :-(

0
esoftbgCommented:
But support Font-attributes like Color, Italic, Bold, Size, Undelined ....
I have an application that stores that into an InterBase database.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Stef MerlijnDeveloperAuthor Commented:
Emil, I've that already.
I just wanted to add some more functionality to the editor.

Does Richedit support protection for deletion of some of the text in the Richedit?

Like:
Default for a new record I load a RTF-document into the datafield which is related to the Richedit.
  DM.TLogboekOmschrijvingDetail.LoadFromFile(ProgMap + '\Sjablonen\LogboekBasisIndeling.rtf');

I would like to protect only the text which is loaded. These are headings like: What have you learned? or What actions must be taken?
The user can fill in the rest, but shouldn't be able to remove these headings.

Glad to hear from you again.
Stef
0
esoftbgCommented:
Hi Stef,

There is an application developed by Borland at:    X:\Program Files\Borland\Delphi7\Demos\RichEdit\richedit.dpr
It is not Database oriented, but it could be easy changed to work with DB ....
It can load and save .rtf files, can change the font attributes of the selected part of the text by using it's Menu Item
Edit, Font which uses FontDialog1 ....
About a protection of part of the text from editting I don't know, it may be possible but ....

Best Regards,
Emil
0
kretzschmarCommented:
about protection there is a solution from me here . . . still searching
0
Stef MerlijnDeveloperAuthor Commented:
I can wait a little. :-)

Maybe the protection must be done in the loaded RTF already. (fieldcodes or something??)
Then I'll be able to see if the Richedit supports it???

Best regards and fine greetings, Stef
0
kretzschmarCommented:
here it comes, its a solution to protect the first x-lines, maybe its axpandable to your needs

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20887455.html#10380217
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Stef MerlijnDeveloperAuthor Commented:
Well that works if the text to protect is always on the same position. But my users add text between the protected parts.

What have you learned?         <- protected
blablabla blabla bla bla blabla <- added by user
blablabla blabla bla bla blabla <- added by user
blablabla blabla bla bla blabla <- added by user

What actions must be taken?  <- protected
blablabla blabla bla bla blabla <- added by user
blablabla blabla bla bla blabla <- added by user

So the protection must be based on the actual string (f.e. What have you learned?) and not on the position in the Richedit, because the position changes when the user is adding his/her text.
0
Stef MerlijnDeveloperAuthor Commented:
Emil and Kretzschmar,

Thanks for thinking with me but I guess I want get an answer to this question.
Shall we split points or withdraw the question?

Regards, Stef
0
kretzschmarCommented:
oops, sorry for not responding

do you have any unique token where could be detect,
that the user is in a should prtotected line?

meikl ;-)
0
Stef MerlijnDeveloperAuthor Commented:
It's OK. I'm just very disapointed :-)

Yes, I have multiple tokens (see below between ===).
In the lines between the tokens the user can add text freely.
The tokens are already rich-formatted (bold, navy, Arial 10).

============================================
Met welke vraag is de cliënt gekomen?
>> users text

Wat ben je tegen gekomen tijdens de sessie?

Welke aandachtspunten zijn er m.b.t. de technieken?

Wat heb je geleerd van deze sessie?

Welke aandachtpunten zijn er m.b.t. overdracht en tegenoverdracht?

Aanvullende opmerkingen?
============================================

Have a go (in dutch: leef je uit).
Stef
0
kretzschmarCommented:
well, ok, you could try following

procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if richedit1.selattibutes.color = clNavy then  
    richedit1.ReadOnly := true
  else
    richedit1.ReadOnly := false;
end;

not tried myself

meikl ;-)
0
Stef MerlijnDeveloperAuthor Commented:
We have a startingpoint.
But, the user can add his/her text also in navy. And then wouldn't be able to change this afterwards.

Maybe when the user starts editing, somehow the text in the current line will be grabbed and checked if it contains one of the tokens I mentioned. If so, the changes are omitted and user gets message (like: "This line can't be changed").
Just don't know if this will work with rich-formatted tokens.

Stef............
0
Stef MerlijnDeveloperAuthor Commented:
I came up with some other problem regarding this.
What if the user selects multiple lines and wants to change some attribute.
How to determine if the protected lines are part of the selection.
0
kretzschmarCommented:
>What if the user selects multiple lines and wants to change some attribute.

well, this cannot be handled this way.
the richedit api provides also to protect chars,
but i never worked with this.

will do a test this evening

meikl ;-)

0
Stef MerlijnDeveloperAuthor Commented:
We'll be in touch. :-)
0
Stef MerlijnDeveloperAuthor Commented:
Hi Meikl,
It's becoming a very long evening :-)

Did you come up with something new or is it a headbreaker?

Stef ;;;;;;;
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.