In the attached program, I'm having this TAdvMemo:

As I resize the form (width-wise), I can see that internally to TAdvMemo, it is a single line (the line reflows to fit the actual width).
But when I save the contents to file using either Lines.SaveToFile or TFile.Write(Lines.Text) it is saved with linebreaks as they are currently in the memo (ie. as I modify the width and re-save, the memo is saved with the new soft-linebreaks as hard-linebreaks in the file).
How do I extract the text without the automatic word-wrapping, ie. as a single, long line?
Project159.zip (3.5 KB)
Use:
BEGIN
AdvMemo1.BeginUpdate;
AdvMemo1.WordWrap := wwNone;
AdvMemo1.Lines.SaveToFile(AdvFileNameEdit1.FileName,TEncoding.UTF8);
AdvMemo1.WordWrap := wwClientWidth;
AdvMemo1.EndUpdate;
Open
END;
Thank you. Done it this way, as an interposer class:
TYPE
TAdvMemo = CLASS(AdvMemo.TAdvMemo)
FUNCTION RawText : STRING;
END;
{ TAdvMemo }
FUNCTION TAdvMemo.RawText : STRING;
VAR
BAK : TWordWrapStyle;
BEGIN
BeginUpdate;
TRY
BAK:=WordWrap; WordWrap:=TWordWrapStyle.wwNone;
TRY
Result:=Lines.Text
FINALLY
WordWrap:=BAK
END
FINALLY
EndUpdate
END
END;
to ensure that previous value of WordWrap was preserved.
Could also be done as a CLASS HELPER.
Updated source:
Project159.zip (3.7 KB)