Recent

Author Topic: [solved] TRichEdit into TRichMemo - can somebody help in code-translation  (Read 816 times)

Nicole

  • Hero Member
  • *****
  • Posts: 970
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]
« Last Edit: July 15, 2022, 04:36:26 pm by Nicole »

Zvoni

  • Hero Member
  • *****
  • Posts: 2319
Re: TRichEdit into TRichMemo - can somebody help in code-translation
« Reply #1 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.
« Last Edit: July 14, 2022, 03:10:54 pm by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Nicole

  • Hero Member
  • *****
  • Posts: 970
Re: TRichEdit into TRichMemo - can somebody help in code-translation
« Reply #2 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