Hello, i have some problems with inserting
collored bold text into my richmemo, i tried to do i like in example of colored text from
https://wiki.freepascal.org/RichMemo/en :
procedure TForm1.AddColorStr(s: string; const col: TColor = clBlack; const NewLine: boolean = TRUE);
begin
with RichMemo1 do
begin
if NewLine then
begin
Lines.Add('');
Lines.Delete(Lines.Count - 1); // avoid double line spacing
end;
SelStart := Length(Text);
SelText := s;
SelLength := Length(s);
SetRangeColor(SelStart, SelLength, col); // replacing this string of code with SetRangeParams(...)
{ SetRangeParams ( SelStart, SelLength,
[tmm_Styles, tmm_Color], // changing Color and Styles only
'', // this is font name - it's not used, thus we can leave it empty
0, // this is font size - it's font size, we can leave it empty
col, // making all the text in the selected region 'col' colored
[fsBold], // adding Bold
[]
);}
// deselect inserted string and position cursor at the end of the text
SelStart := Length(Text);
SelText := '';
end;
end;
But i got result i didn't unexpected:
What i expect and got with SetRangeColor() using AddColorStr(' this text is green ', clGReen, false);
RichMemo:
textinmemoblablabla
this text is green normaltexblablabla
but when i replace SetRangeColor() with SetRangeParams() and use AddColorStr(' this text is green ', clGReen, false); i get my " this text is green " added in new line:
RichMemo:
textinmemoblablabla
this text is green normaltexblablabla
Why text starting from new line and how i can fix it? Any examples or advice for this code?
I am trying to make a function for filling Richmemo with text not from new line and with color+bold params.
Andriy