Knowledge Base Article
KB10668 - How can I store/read the configuration for in-memory (non-persistent) layer? I tried to use the project file, but a non-persistent layer is ignored.
This is logical. Project files contain no knowledge of how to recreate a non-persistent layer. You must add such action on your own.
For example:
procedure TfrmMain.createLayerAndSaveConfig;
var
ll : TGIS_LayerVector ;
begin
ll := TGIS_LayerVector.Create ;
ll.StoreParamsInProject := False ; // DK8 only
ll.ConfigName := 'mylayer.ini' ;
ll.Params.Area.Color := clRed;
ll.WriteConfig ; // copy layer parmeters to configuration file
ll.SaveAll ; // to save all changes including ini file
end;
procedure TfrmMain.createLayerAndReadConfig;
var
ll : TGIS_LayerVector ;
begin
ll := TGIS_LayerVector.Create ;
ll.StoreParamsInProject := False ; // DK8 only
ll.ConfigName := 'mylayer.ini' ;
ll.RereadConfig ;
if ll.Params.Area.Color = clRed then begin
ShowMesssage( 'Bingo!')
end ;
end;
Also, you can use TGIS_Viewer.OnLayerAdd & OnLayerDelete to automate such process.
DK9 Note
With the introduction of DK9 TGIS_LayerAbstract.StoreParamsInProject has been removed. Parameters will be read write form the .INI file if such file exists. If you want to create a new .INI file just create an empty text file just before calling WriteConfig method.
Created: 2006-01-10, Modified: 2010-04-22
|