[solved] TRichEdit - what to use in Lazarus? lazarus / 21-General ---------------------------------------------------------------------- Nicole · 2022-07-11 14:34 Delphi: var myRichEdit: TRichEdit; begin   myRichEdit.SaveToFile('myFile'); end; ________________________ Lazarus: Var mySomething: TSomething; begin   mySomething.LoadFromFile('myfile'); end; ___________________ ► What is a good idea to use as "Something" in Lazarus? Thanks PS: about lzRichEdit: I gave it a try, but it did not work, because of too many compilation errors. ---------------------------------------------------------------------- rvk · 2022-07-11 14:54 Quote from: Nicole on July 11, 2022, 04:34:54 pmPS: about lzRichEdit: I gave it a try, but it did not work, because of too many compilation errors. Where did you get lzTichEdit from? What version of Lazarus and which OS are you using? You can try RichMemo in the Online Packagemanager. ---------------------------------------------------------------------- Nicole · 2022-07-11 15:00 Thank you for your answer. Version 2.2.2 I heard about Richmemo. But I cannot see it anywhere. you said: "in the Online Packagemanager" - pls slowly for stupid. Where can I find a TRichMemo package? ---------------------------------------------------------------------- rvk · 2022-07-11 15:05 Quote from: Nicole on July 11, 2022, 05:00:09 pmyou said: "in the Online Packagemanager" - pls slowly for stupid. Where can I find a TRichMemo package? In lazarus click Package (in the menu) and choose Online Package Manager. Type rich in the searchbar. Now you will get the packages which support rtf. Check RichMenu and press Install. Let it download, compile and restart. Now there is a TRichMemo under the Common Controls (at the end). This one should be largely compatible with TRichEdit. ---------------------------------------------------------------------- Handoko · 2022-07-11 15:11 You can install RichEdit by using Online Package Manager: Lazarus main menu > Package > Online Package Manager > enable the checkbox of RichMemo > Install Wait until it finishes downloading all necessary files and answer yes if it asks to rebuild the IDE. If you fails to install RichEdit using Online Package Manager, read here: https://forum.lazarus.freepascal.org/index.php/topic,59567.msg444097.h tml#msg444097 ---------------------------------------------------------------------- rvk · 2022-07-11 15:18 O, BTW, I said it was largely compatible but there isn't a LoadFromFile. And TRichMemo.Lines.LoadFromFile doesn't work for TRichMemo. At least, not that I could find in the 30 seconds I searched  There is LoadFromText (from stream) but you could easily create a helper function for LoadFromFile. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TRichMemoHelper = class helper for TRichMemo  public    procedure LoadRTFFromFile(const FileName: string);  end;   procedure TRichMemoHelper.LoadRTFFromFile(const FileName: string);  var    Stream: TStream;  begin    Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);    try      Self.LoadRichText(Stream);    finally      Stream.Free;    end;  end; procedure TForm1.Button1Click(Sender: TObject);begin  // RichMemo1.Lines.LoadFromFile('c:\temp\test.rtf'); // doesn't work  RichMemo1.LoadRTFFromFile('c:\temp\test.rtf');end; (took me another 30 seconds to write  ) ---------------------------------------------------------------------- JLWest · 2022-09-21 06:54 I get an error on Line 2 - unit1.pas(17,3) Error: An interface, helper or Objective-C protocol or category cannot contain fields ---------------------------------------------------------------------- rvk · 2022-09-21 07:02 Quote from: JLWest on September 21, 2022, 08:54:53 amI get an error on Line 2 - unit1.pas(17,3) Error: An interface, helper or Objective-C protocol or category cannot contain fields Show your code because for me this worked. You'll need to put this code inside your own unit, it isn't a complete standalone unit. Otherwise you could use the LoadRTFFile from the RichMemoUtils unit. ---------------------------------------------------------------------- Nicole · 2022-09-21 21:40 Oh yes, it does. You must know the trick, which was told me by a good guy in this forum some weeks ago. It reads: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i LoadRTFFile(RichMemo1, RichEdit_yourFileToLoad); if you would load from plain text, you have to use Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i RichMemo.Lines.LoadFromFile (yourFileToLoad);