I can't seem to make a TTMSFNCRichEditor load a file with an image.
I have a TTMSFNCRichEditor named introMemo on a form, and I add some text and a jpeg image to it.
I save it with the following code:
try
try
result := False;
filePathGetter := TSegmentFileInfo.Create;
fileName := 'step' + intToStr(tabNumI);
pageFileName := filePathGetter.getNewConceptIntroPathName(fileName);
editorIO := TTMSFNCRichEditorRTFIO.Create(nil);
if assigned(introMemo) then
begin
editorIO.RichEditor := introMemo;
editorIO.Save(pageFileName);
result := True;
end;
except
result := False;
end;
finally
editorIO.Free;
filePathGetter.free;
end;
This part seems to work, and I can open the resulting file with openoffice writer, and it looks OK.
Then I try to open the file into another TTMSFNCRichEditor component, using this code:
try
.
.
.
.
editorIO := TTMSFNCRichEditorRTFIO.create(nil);
editorIO.RichEditor := introMemo;
editorIO.Load(pageFileName);
.
.
.
finally
editorIO.Free;
end;
This fails with an access violation at "FromPicture.SaveToStream(ms)" below:
procedure AssignPicture(FromPicture: TPicture; ToPicture: TGDIPPicture);
{$IFDEF FMXLIB}
var
ms: TMemoryStream;
{$ENDIF}
begin
{$IFNDEF FMXLIB}
ToPicture.Assign(FromPicture);
{$ENDIF}
{$IFDEF FMXLIB}
ms := TMemoryStream.Create;
try
FromPicture.SaveToStream(ms);
ms.Position := 0;
ToPicture.LoadFromStream(ms);
finally
ms.Free;
end;
{$ENDIF}
end;
If the original file just has text, and no picture, it saves and opens again without error.
Please note that my ACTUAL goal is to save to a stream, store it as a blob in mysql, then open it again in the richEditor later. That also failed with an access violation, but it had so many moving parts that I made this as a more simple example to show the problem.
I would deeply appreciate any help.
Thanks
Art