[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Richedit - formatting

Posted on 2002-05-02
11
Medium Priority
?
432 Views
Last Modified: 2013-11-22
Hi there!
Problem: I want to format parts of the strings while adding them to the Richedit. Currently:

procedure TForm1.Button1Click(Sender: TObject);
var tst,tend:integer;
begin
 with RichEdit1,Richedit1.SelAttributes do begin

  TSt:=Length(Text);
  Text:=Text+'Blue simple ';
  TEnd:=Length(Text);
  SelStart:=TSt;
  SelLength:=TEnd-TSt;
  Size:=8;
  Color:=clBlue;
  Style:=[];


  TSt:=Length(Text);
  Text:=Text+'Green Italic ';
  TEnd:=Length(Text);
  SelStart:=TSt;
  SelLength:=TEnd-TSt;
  Size:=8;
  Color:=clGreen;
  Style:=[fsItalic];
 end;
end;

it works fine - once :)
When I click Button1 again, I have previous "Green Italic" formatted as blue simple; the last Green Italic appears correctly.

What I'm trying to do is to have as simple as possible way how to change text attributes within the line, preferrably before adding it to RichEdit.

Thanks in advance, this should be simple, but 123 points anyway :)

W_Fox
0
Comment
Question by:W_Fox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +1
11 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6986904
no way,
exceptyou write the string wiht the rtf-tokens and stream (no add) this into the richedit with the win api em_streamin and usage of the editstream structure

sorry no easy way to color a string before adding it into a richedit

meikl ;-)
0
 

Author Comment

by:W_Fox
ID: 6986916
OK, what about changing after adding? Beginupdate and EndUpdate (IIRC) should help avoid flickering...

W_Fox
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6986959
yes,
additional you can with the message em_hideselection toggle the selection-showing on/off
0
Industry Leaders: 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!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6986978
there may also a workaround
using a second hidden richedit and
preformat there the line and then
copy/paste the line via cliboard
into the first richedit

just a workaround

meikl ;-)
0
 
LVL 8

Accepted Solution

by:
Cesario earned 492 total points
ID: 6986988
This is what you need

procedure TForm1.Button1Click(Sender: TObject);
begin
  with RichEdit1,Richedit1.SelAttributes do
  begin
   SelStart := GetTextLen;
   Size     :=8;
   Color    :=clBlue;
   Style    :=[];
   selText  := 'Blue simple ';

   SelStart := GetTextLen;
   Size     :=8;
   Color    :=clgreen;
   Style    :=[fsItalic];
   selText  := 'Green Italic ';
  end;
end;
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 6986995
Kudos Cesario!!

0
 
LVL 8

Expert Comment

by:Cesario
ID: 6986999
Meikl, its possible ;-)

Best Regards

Cesario
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6987179
well, you wrote your string in parts,
didn't know, if this solves the question?

>how to change text attributes within the
>line, preferrably before adding it to RichEdit.

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6987189
didn't know, if this solves the question?
could be :-)
0
 

Author Comment

by:W_Fox
ID: 6988051
That's exactly what I need, thanks, Cesario!
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6988164
well, seems i have misread the question :-(

good work, cesario :-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

649 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