Lazarus

Programming => Packages and Libraries => RichMemo => Topic started by: Nicole on July 14, 2022, 02:27:40 pm

Title: [solved] TRichEdit into TRichMemo - can somebody help in code-translation
Post by: Nicole on July 14, 2022, 02:27:40 pm
I want to portate the source below from Delphi TRichEdit into Lazarus TRichMemo.
It does nothing else, but work as alternating button to switch "formatted bold" on or off.

My problem, I do not know, how to translate:
"RichEdit_WICHTIG.SelAttributes.Style=[fsBold]"


Code: Pascal  [Select][+][-]
  1. [pre]// der ausgewählte Text wird fett gedruckt bzw. das Setting revidiert
  2. procedure TForm_KalenderMain.SpeedButton_fettClick(Sender: TObject);
  3. begin  
  4.    if RichEdit_WICHTIG.SelAttributes.Style=[fsBold] then begin
  5.        RichEdit_WICHTIG.SelAttributes.Style:=[]; // auf normal = default setzen
  6.        SpeedButton_fett.Font.Style:=[];
  7.        SpeedButton_fett.Down:=false;
  8.        exit; end;      // wenn es bereits fett ist, => wieder normal
  9.  
  10.     RichEdit_WICHTIG.SelAttributes.Style:= [fsBold];
  11.     SpeedButton_fett.Font.Style:= [fsBold];
  12. end;[/pre]
[/color]
Title: Re: TRichEdit into TRichMemo - can somebody help in code-translation
Post by: Zvoni on July 14, 2022, 02:55:06 pm
First guess: https://wiki.freepascal.org/RichMemo#SetRangeParams

EDIT:
Second Guess: https://wiki.freepascal.org/RichMemo#TRichEditForMemo
Quote
The class helper that implements RichEdit programmatic interface.

Third guess: https://wiki.freepascal.org/RichMemo#.28Delphi.29_RichEdit_like_interface
Quote
you can use RichMemoHelpers unit (fpc 2.6.0 or later required) and use methods provided by class Helpers that should; Currently SelAttributes and Paragraph properties are implemented.
Title: Re: TRichEdit into TRichMemo - can somebody help in code-translation
Post by: Nicole on July 15, 2022, 04:36:09 pm
Thank you for the links!

This does it:

set to bold
   RichMemo_Notizen.SetRangeParams(RichMemo_Notizen.SelStart,RichMemo_Notizen.SelLength,[tmm_Styles],'',0,0,[fsbold], [])


set not not bold
   RichMemo_Notizen.SetRangeParams(RichMemo_Notizen.SelStart,RichMemo_Notizen.SelLength,[tmm_Styles],'',0,0,[], [fsbold]);
TinyPortal © 2005-2018