I want to read each line in order to measure the width of each line of a text... Is there an equivalent of RichEdit->Lines->Strings[int] ?
Thank you
I want to read each line in order to measure the width of each line of a text... Is there an equivalent of RichEdit->Lines->Strings[int] ?
Thank you
TTMSFNCRichEditor content is not organised line by line, one of the reasons being that it always renders its content as wordwrapped text by default.
You can get the content as plain text via
function GetText(RichEditor: TTMSFNCRichEditor): TStringList;
var
AStream: TStringStream;
i: integer;
el: TREElement;
begin
AStream := TStringStream.Create('');
try
for i := 0 to RichEditor.Context.Content.Count - 1 do
begin
el := RichEditor.Context.Content.Items[i];
if el is TLineBreakElement then
AStream.WriteString(#13#10);
if el is TTextElement then
AStream.WriteString(el.Text);
end;
AStream.Position := 0;
Result := TStringList.Create;
Result.LoadFromStream(AStream);
finally
AStream.Free;
end;
end;
var
sl: TStringList;
begin
sl := GetText(TMSFNCRichEditor1);
memo1.Lines.Assign(sl);
sl.Free;
end;
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.