FNC Richtexteditor

Hi, i am having problems with the FNCRichtexteditor.

i want to save the content to a database so i am converting the entered text to a stream which i am converting tot base64 to save in the database.

so saving :
tmpS:=TMemoryStream.Create;
MEMO.SaveToStream(tmpS);
tmpS.Position:=0;
Base64String:=TTMSFNCUtils.SaveStreamToBase64(tmpS);
(the base64string is save in a SQL server table (varchar(max)

on loading :

tmpS:=TMemorystream.Create;
try
TTMSFNCUtils.LoadStreamFromBase64(pDS.FieldByName('comm').AsString,tmpS);
tmpS.Position:=0;
MEMOa_iu_comm.BeginUpdate;
MEMOa_iu_comm.Clear;
MEMOa_iu_Comm.LoadFromStream(tmpS);
MEMOa_iu_comm.EndUpdate;
finally
tmpS.Free;
end;

this works perfect for any text i copy in the richtext editor.
also when i add text manually (by typing) this works perfect
but when i enter some text manually and change some setting (bold, italic), the application blocks

while debugging i can see that at the MEMOa_iu_Comm.LoadFromStream(tmpS) stops the application (no error, no exception)

maybe also important to know is that i add multiple richtexteditors at runtime to a Layout (for each record in the database there is a richtexteditor added to a layout. But that works perfect;

any ideas ?

I use something like this and have never had a problem - the code comes from Lazarus so converting string to base64 and vice versa may be different than Delphi

uses
  base64;

procedure TForm1.SaveREtoDBClick(Sender: TObject);
begin
  query.SQL.Clear;
  query.SQL.Add(' update table set value=:revalue where id=:id ');
  query.ParamByName('id').AsInteger := RowID;
  query.ParamByName('revalue').AsString := EncodeStringBase64(TMSFNCRichEditor1.ContentAsRTE);
  query.ExecSQL;
end;

procedure TForm1.LoadREfromDBClick(Sender: TObject);
begin
  query.SQL.Clear;
  query.SQL.Add(' select value from table where id=:id ');
  query.ParamByName('id').AsInteger := RowID;
  query.Open;
  TMSFNCRichEditor1.ContentAsRTE := DecodeStringBase64(query.FieldByName('value').AsString);
  query.Close;
end;          

Thank you, but this does not solve the issue.
while debugging i can now see that the application freezes at the
tmpRTE.ContentAsRTE:=TNetEncoding.Base64.Decode(DSRd_d.DataSet.FieldByName('comm').AsString); line.
so ther must be a issue with the Texteditor, not with the fact that i use a Stream

after further testing, it seems that the freezes comes from this linde of code :

RichTextEditor.Align:=TAlignLayout.top

if i remove this line of code, it works correct, but i need to align the editor in the layout.... otherwise it is not correctly displayed.

so this works (but is not displayed well) :

try
  tmpRTE.Parent:=tmpBodyLayout;
  tmpRTE.AdaptToStyle:=true;
  tmpRTE.ReadOnly:=true;
tmpRTE.ContentAsRTE:=TNetEncoding.Base64.Decode(DSRd_d.DataSet.FieldByName('comm').AsString);
  //tmpRTE.Align:=TAlignLayout.Top;
finally
  tmpRTE.EndUpdate;
end;