Hi Sergey,
can you add something like that in TRVStyleTemplateCollection?
function TRVStyleTemplateCollection.SaveToStreamRVST(Stream: TStream; Units: TRVStyleUnits): Boolean;
var
ini: TMemIniFile;
begin
Result := False;
try
ini := TMemIniFile.Create(Stream, TEncoding.UTF8);
try
ini.EraseSection(STYLETEMPLATEINISECTION);
SaveToINI(ini, STYLETEMPLATEINISECTION);
ini.WriteInteger(STYLETEMPLATEINISECTION, RVINI_UNITS, Ord(Units));
ini.UpdateFile;
finally
ini.Free;
end;
Result := True;
except
end;
end;
function TRVStyleTemplateCollection.LoadFromStreamRVST(Stream: TStream; Units: TRVStyleUnits; ARVStyle: TRVStyle = nil): Boolean;
var
ini: TMemIniFile;
FileUnits: TRVStyleUnits;
begin
Result := False;
try
ini := TMemIniFile.Create(Stream, TEncoding.UTF8);
try
LoadFromINI(ini, STYLETEMPLATEINISECTION);
FileUnits := TRVStyleUnits(ini.ReadInteger(STYLETEMPLATEINISECTION,
RVINI_UNITS, Ord(rvstuPixels)));
UpdateReferences;
finally
ini.Free;
end;
if FileUnits <> Units then
begin
if ARVStyle = nil then
ARVStyle := FOwner as TRVStyle;
ConvertToDifferentUnits(ARVStyle, FileUnits, Units);
end;
Result := True;
except
end;
end;
For now I add this code manually in every engine update. It would be great to see this methods in next release of TRichView
TRVStyleTemplateCollection : SaveToStreamRVST, LoadFromStreamRVST
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: TRVStyleTemplateCollection : SaveToStreamRVST, LoadFromStreamRVST
Ok, I'll add it in the next update.
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: TRVStyleTemplateCollection : SaveToStreamRVST, LoadFromStreamRVST
I did not know that TMemIniFile can be linked to a stream. I checked, this feature was added in RAD Studio 10.3
Re: TRVStyleTemplateCollection : SaveToStreamRVST, LoadFromStreamRVST
Thank you, Sergey!
>> I did not know that TMemIniFile can be linked to a stream. I checked, this feature was added in RAD Studio 10.3
work correctly with 10.2, don’t know for earlier versions
>> I did not know that TMemIniFile can be linked to a stream. I checked, this feature was added in RAD Studio 10.3
work correctly with 10.2, don’t know for earlier versions
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: TRVStyleTemplateCollection : SaveToStreamRVST, LoadFromStreamRVST
It's strange. In 10.2 source, I can see 3 constructors for TMemIniFile, all of them has FileName, not Stream parameter.
"ini.UpdateFile" code required!
Hi Sergey,
method SaveToStreamRVST does not save data in ini file. To save the data, at the end of the operation you need to call the method "ini.UpdateFile":
...
try
ini.EraseSection(STYLETEMPLATEINISECTION);
SaveToINI(ini, STYLETEMPLATEINISECTION);
ini.WriteInteger(STYLETEMPLATEINISECTION, RVINI_UNITS, Ord(Units));
ini.UpdateFile; // <<<----- THIS CODE REQUIRED
finally
ini.Free;
end;
...
method SaveToStreamRVST does not save data in ini file. To save the data, at the end of the operation you need to call the method "ini.UpdateFile":
...
try
ini.EraseSection(STYLETEMPLATEINISECTION);
SaveToINI(ini, STYLETEMPLATEINISECTION);
ini.WriteInteger(STYLETEMPLATEINISECTION, RVINI_UNITS, Ord(Units));
ini.UpdateFile; // <<<----- THIS CODE REQUIRED
finally
ini.Free;
end;
...
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: TRVStyleTemplateCollection : SaveToStreamRVST, LoadFromStreamRVST
Thank you! It is fixed in TRichView v18.5.1