Hello,
after having successfully installed the
RichMemo component on Windows 8 64bit, I wonder why no procedure exists which with you can add formatted text. You can only modify the format of existing text.
That's why I want to recommend this procedure in RichMemo.pas
l.207
procedure TCustomRichMemo.AddFormattedString(str: string; fnt: TFontParams);
// fnt can be passed with GetFontParams or manually created
var
i, j: integer;
begin
i := Length(Lines.Text) - Lines.Count;// cr as #10#13 is counted only once so subtract it once
j := Length(str) + 1; // +1 to make the cr the same format
Lines.Add(str);
SetTextAttributes(i, j, fnt); //apply now
end;
and add l.55
public
procedure AddFormattedString(str: string; fnt: TFontParams);
Maybe you can tell me why this is not yet included?
Edit: extension:
// ####
// fnt can be passed with GetFontParams or manually created
// wordwrap=false !
procedure TCustomRichMemo.AddFormattedString(str: string; fnt: TFontParams);
var
i, j: integer;
begin
i := Length(Lines.Text) - Lines.Count; //start
j := Length(str) + 1; //length (+1: to make CR also "fnt")
Lines.Add(str); //just add the string
SetTextAttributes(i, j, fnt); //apply formatting
end;
// adding two strings with each different style
procedure TCustomRichMemo.AddFormattedString2(str1, str2: string;
fnt1, fnt2: TFontParams);
var
i, j, k: integer;
begin
i := Length(Lines.Text) - Lines.Count;
j := Length(str1);
k := Length(str2) + 1;
Lines.Add(str1 + str2);
SetTextAttributes(i, j, fnt1);
SetTextAttributes(i + j, k, fnt2);
end;
Regards