Reputation: 325
I want to load text from an external INI file to a TRichEditViewer
, but I don't know how.
Here is my code so far (see CH_toolbar.RTFText):
{CH_toolbar}
CH_toolbar := TRichEditViewer.Create(SPPage);
CH_toolbar.Parent := SPPage.Surface;
CH_toolbar.Left := ScaleX(0);
CH_toolbar.Top := Title.Top + Title.Height + 10 ;
CH_toolbar.Width := ScaleX(480);
CH_toolbar.Height := ScaleY(80);
CH_toolbar.TabOrder := 1;
CH_toolbar.Font.Name := 'Verdana';
CH_toolbar.Color := -16777211;
CH_toolbar.ScrollBars := ssVertical;
CH_toolbar.RTFText := ExpandConstant(#ReadIni("setupPages", "setupValues", "SPEulatext", "")) ;
How do I insertSPEulatext
value in CH_toolbar.RTFText
?
Upvotes: 1
Views: 834
Reputation: 24283
#ReadIni
is executed at compile time so it inserts a very long (unquoted) string literal.
If you want to load it at run time, use the GetIniString()
function:
CH_toolbar.RTFText := GetIniString('setupValues', 'SPEulatext', '', 'setupPages');
(setupPages
is the file name in both cases)
Note that Ini strings have a limited length and can't contain new line characters so an INI file is probably a bad choice for this.
Alternatively, you can load an RTF or text file directly:
ExtractTemporaryFile('lgpl-3.0.txt');
LoadStringFromFile(ExpandConstant('{tmp}/lgpl-3.0.txt'), LGPLText);
LGPLPage.RichEditViewer.RTFText := LGPLText;
Upvotes: 2