KMemo and DBKMemo? lazarus / 31-LCL ---------------------------------------------------------------------- MoellerCLaus · 2020-03-08 17:28 I was wondering is there a DB version of KMemo (with all the fine RTF capabilities) ---------------------------------------------------------------------- jamie · 2020-03-08 18:04 you know you can connect any control you wish to a TdataSource.Event triggers.. with those triggers you can then update your controls. ---------------------------------------------------------------------- MoellerCLaus · 2020-03-15 17:20 Thanks But it seems that using KMemo- or RichMemo-streams can not store as BLOB fields into a SQLLite database field defined as BLOB.   I must find another work around. It used to work with Firebird but somehow SQLLite is different. I am using Zeos components. ---------------------------------------------------------------------- balazsszekely · 2020-03-15 17:38 Did you try with blobstream? Something like this: 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 var  BlobStream: TStream;begin  BlobStream := SQLQuery1.CreateBlobStream(SQLQuery1.FieldByName('YOURBLOBFIELD'), bmRead);  try    RichMemo1.LoadRichText(BlobStream);  finally    BlobStream.Free;  end;    end; You do the reverse when saving. ---------------------------------------------------------------------- MoellerCLaus · 2020-03-15 17:49 Thanks for reaching out I will argue YES; see below. It works fine as long as I stay in the form. When I start form again data in BLOB are lost; not other changed fields. 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 procedure TUdsendelseForm.HentEditor;Var BlobField : TField;    fs : TStream; Begin  fs := TMemoryStream.Create;  try    fs := ZQueryMailDe f.CreateBlobStream(ZQueryMailDef.FieldByName('FoelgeTekst'), bmRead);    KMemo1.LoadFromRTFStream(fs);  except  end;  holbaek_editor_form := Tholbaek_editor_form.Create(Self);  fs.Position := 0;  holbaek_editor_form.KMemoFrame1.Editor.LoadFromRTFStream(fs);  holbaek_editor_form.ShowModal;  If holbaek_editor_form.KMemoFrame1.Editor.Modified Then    Begin      BlobField := ZQueryMailDef.FieldByName('FoelgeTekst');      fs.free;    fs := ZQueryMailDef.CreateBlobStream(BlobField,bmWrite);      fs.position := 0;      ZQueryMailDef.Edit;      holbaek_editor_form.KMemoFrame1.Editor.SaveToRTFStream(fs);      try      ZQueryMailDef.Post;        ZQueryMailDef.ApplyUpdates;      Except        ShowMessage('Error');      end;      fs.Free;    end;  holbaek_editor_form.Free;End; ---------------------------------------------------------------------- balazsszekely · 2020-03-15 17:57 @MoellerCLaus Please try something for me, it will seam counter-intuitive.  Just remove the final fs.Free and see what happens. 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       Except        ShowMessage('Error');      end;      //fs.Free; <-- this one    end;  holbaek_editor_form.Free;End; ---------------------------------------------------------------------- MoellerCLaus · 2020-03-15 18:28 If I take out fs.free. Nothing gets into the memo field. I have on the form (for testing) a DBMemo field to monitor. Which shows the right RTF codes - but without fs.free nothing comes up? Strange ---------------------------------------------------------------------- MoellerCLaus · 2020-03-16 09:52 Well I think there is a bug in KMemo.SaveToStream I tried to save to file - and it worked out well. Quoteprocedure TForm1.Button1Click(Sender: TObject); Var Blob : TBlobField; Begin   Blob := TBlobField(ZQuery1.FieldByName('FoelgeTekst'));   Blob.SaveToFile('Test.rtf');   holbaek_editor_form := Tholbaek_editor_form.Create(Self);   holbaek_editor_form.KMemoFrame1.Editor.LoadFromFile('Test.rtf');   holbaek_editor_form.ShowModal;   If holbaek_editor_form.KMemoFrame1.Editor.Modified Then     Begin       ZQuery1.Edit;       holbaek_editor_form.KMemoFrame1.Editor.SaveToRTF('Test1.rtf',fal se,false);       //KMemo1.LoadFromRTF('Test1.rtf');       Blob := TBlobField(ZQuery1.FieldByName('FoelgeTekst'));       Blob.LoadFromFile('Test1.rtf');       try         ZQuery1.Post;       Except         ShowMessage('Error');       end;     end;   holbaek_editor_form.Free; end; I will try to deep dive into KMemo Stream loading/Saving which I see as a contender to RichMemo  First thing seen doing KMemo.LoadFromStream is that an extra CR+LF is added at the top. ---------------------------------------------------------------------- balazsszekely · 2020-03-16 10:48 @MoellerCLaus QuoteI will try to deep dive into KMemo Stream loading/Saving which I see as a contender to RichMemo  First thing seen doing KMemo.LoadFromStream is that an extra CR+LF is added at the top.Thanks for the feedback. I tested the blobstream idea with firebird and richmemo and everything works well. Maybee KMemo has a bug. ---------------------------------------------------------------------- MoellerCLaus · 2020-03-16 11:27 Thanks - Yeah The following attached code works with KMemo and streams. But If edited in KFrame (the demo editor for KMemo) and saving to the stream an extra line is inserted at the top I used RichMemo in an earlier application and even made a DBRichMemo. But I was fund of the capabilities in KMemo. I am close to get it right - except for adding a line 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 procedure TForm1.Button1Click(Sender: TObject);Var Blob : TBlobField;    fs   : TStream;Begin  fs := TMemoryStream.Create;  Blob := TBlobField(ZQuery1.FieldByName('FoelgeTekst'));  Blob.SaveToStream(fs); // .SaveToFile('Test.rtf');  holbaek_editor_form := Tholbaek_editor_form.Create(Self);  fs.position := 0;  holbaek_editor_form.KMemoFrame1.Editor.LoadFromRTFStream(fs); //LoadFromRTF('Test.rtf');  holbaek_editor_form.ShowModal;  fs.Free;  If holbaek_editor_form.KMemoFrame1.Editor.Modified Then    Begin      ZQuery1.Edit;      fs := TMemoryStream.Create;      holbaek_editor_form.KMemoFrame1.Editor.SaveToRTFStream(fs,False, False);   //SaveToRTF('Test1.rtf',false,false);      Blob := TBlobField(ZQuery1.FieldByName('FoelgeTekst'));      fs.position := 0;      Blob.LoadFromStream(fs);   //LoadFromFile('Test1.rtf');      try        ZQuery1.Post;      Except        ShowMessage('Error');    end;      fs.free;    end;  holbaek_editor_form.Free;end; ---------------------------------------------------------------------- MoellerCLaus · 2020-04-20 18:46 my mistake. I did not worked because the declarations were made in the procedure and will disappear at the heap after closure. Declaring them as part of the component/form everything works fine. My pascal is rusty.