Recent

Author Topic: Rich text viewer  (Read 2499 times)

petevick

  • Sr. Member
  • ****
  • Posts: 347
Rich text viewer
« on: February 28, 2022, 01:39:31 pm »
I want to display a Rich Text File. From an online search I'm lead to believe that either LazRichView or RichMemo will do the trick. I've tried installing RichMemo but it will not install, just a 'cannot install package' message. LazRichView did install, but for the life of me I cannot find any method to load/read an external file. I've found reference to the Delphi version which has a LoadRTF method, but that does not exist for Lazarus.
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Re: Rich text viewer
« Reply #1 on: February 28, 2022, 01:43:52 pm »

petevick

  • Sr. Member
  • ****
  • Posts: 347
Re: Rich text viewer
« Reply #2 on: March 01, 2022, 10:34:21 am »
Related forum part
https://forum.lazarus.freepascal.org/index.php/board,71.0.html
thanks for the reply, but my question related to the LazRichView component and specifically how to load an rtf file into it.
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Rich text viewer
« Reply #3 on: March 01, 2022, 11:44:00 am »
I've tried installing RichMemo but it will not install, just a 'cannot install package' message.
Just tried this a few days ago and it worked flawlessly (Laz 2.2.0/FPC 3.2.2, RichMemo from OPM). Maybe I should draw your attention to the fact that RichMemo comes in two packages. The richmemopackage.lpk is the run-time package and cannot be installed. In the subfolder "ide" you find the richmemo_design.lpk designtime package - this is the one which must be installed. When you install the package from OPM (which may be a bit out-dated in comparison with the author's development version on github, though) you need not care about such details.

LazRichView did install, but for the life of me I cannot find any method to load/read an external file. I've found reference to the Delphi version which has a LoadRTF method, but that does not exist for Lazarus.
I seems you are right - I cannot find something like LoadFromFile either.

balazsszekely

  • Guest
Re: Rich text viewer
« Reply #4 on: March 01, 2022, 11:53:16 am »
IIRC there is a LoadRichText, or something similar:
Code: Pascal  [Select][+][-]
  1. var
  2.   FS: TFileStream;
  3. begin
  4.   FS := TFileStream.Create(PathToRTf, fmOpenRead or fmShareDenyNone);
  5.   try
  6.     RichMemo1.LoadRichText(FS);
  7.   finally
  8.     FS.Free
  9.   end;
  10. end;

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Rich text viewer
« Reply #5 on: March 01, 2022, 12:06:30 pm »
Yes, for RichMemo, but AFAICS not for RichView.

petevick

  • Sr. Member
  • ****
  • Posts: 347
Re: Rich text viewer
« Reply #6 on: March 01, 2022, 12:26:16 pm »
Just tried this a few days ago and it worked flawlessly (Laz 2.2.0/FPC 3.2.2, RichMemo from OPM). Maybe I should draw your attention to the fact that RichMemo comes in two packages. The richmemopackage.lpk is the run-time package and cannot be installed. In the subfolder "ide" you find the richmemo_design.lpk designtime package - this is the one which must be installed. When you install the package from OPM (which may be a bit out-dated in comparison with the author's development version on github, though) you need not care about such details.
I was installing it from the OPM, but both lpk packages give a "Cannot compile package" error, and like yourself I'm using Laz 2.2.0 and FPC 3.2.2.  :(
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Rich text viewer
« Reply #7 on: March 01, 2022, 01:38:25 pm »
I should read your signature. I am on Windows, you are on Linux...

Tried the same on Linux Mint 10.2 and confirm the issue now. I also tried the version on the author's github - same issue.

Since the non-compiling line is inside an {$IFDEF} I looked at the package options and found the define RMLCLTRUNK which is not active. After activating it I could compile both packages on Mint.

So, these are the steps how you could make it work for yourself:
  • Open the richmemopackage.lpk in Lazarus ("Package" > "Open Package File")
  • Select "Options" > "Compiler Options" > "Custom Options". Click "Defines..." and check the item RMLCLTRUNK in the checklistbox > "OK"
  • Now you should be able to compile the richmemopackage.lpk.
  • Finally load richmemo_design.lpk and install it (click "Use" > "Install")


petevick

  • Sr. Member
  • ****
  • Posts: 347
Re: Rich text viewer
« Reply #8 on: March 01, 2022, 02:06:48 pm »
  • Finally load richmemo_design.lpk and install it (click "Use" > "Install")
It all went well until this last step, I'm not sure how/where you would 'load' the lpk, but the "Install" option was greyed out. I did manage to install it though via Package>Install/Uninstall packages.

That's brilliant work wp, thank you for that  ;D
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

petevick

  • Sr. Member
  • ****
  • Posts: 347
Re: Rich text viewer
« Reply #9 on: March 01, 2022, 04:37:20 pm »
and as if by magic, I came across this in the wiki - https://wiki.freepascal.org/File:rmlcltrunkdefine.png
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Rich text viewer
« Reply #10 on: March 01, 2022, 04:38:59 pm »
  • Finally load richmemo_design.lpk and install it (click "Use" > "Install")
It all went well until this last step, I'm not sure how/where you would 'load' the lpk
Well, maybe my description was too short here. Go to "Package" > "Open Package file". Navigate to the subfolder "ide" of the folder into which you had unzipped the RichMemo download. Select the file richmemo_design.lpk which must exist in this folder. Although not needed, it may be a good idea to check whether the design-time package compiles: Click "Compile". When ok, click on "Use" > "Install" finally.

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Rich text viewer
« Reply #11 on: March 01, 2022, 04:40:41 pm »

 

TinyPortal © 2005-2018