W_Fox
asked on
Richedit - formatting
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.SelAtt ributes 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
Problem: I want to format parts of the strings while adding them to the Richedit. Currently:
procedure TForm1.Button1Click(Sender
var tst,tend:integer;
begin
with RichEdit1,Richedit1.SelAtt
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
ASKER
OK, what about changing after adding? Beginupdate and EndUpdate (IIRC) should help avoid flickering...
W_Fox
W_Fox
yes,
additional you can with the message em_hideselection toggle the selection-showing on/off
additional you can with the message em_hideselection toggle the selection-showing on/off
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 ;-)
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 ;-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Kudos Cesario!!
Meikl, its possible ;-)
Best Regards
Cesario
Best Regards
Cesario
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 ;-)
didn't know, if this solves the question?
>how to change text attributes within the
>line, preferrably before adding it to RichEdit.
meikl ;-)
didn't know, if this solves the question?
could be :-)
could be :-)
ASKER
That's exactly what I need, thanks, Cesario!
well, seems i have misread the question :-(
good work, cesario :-)
good work, cesario :-)
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 ;-)