DeepSoftware.Ru
ComponentsProgramsArticlesLinksContacts

    Home     Components    Storage Library    Case Study

Component
Shortcuts
Support


Storage Library - Case Study

Save settings in application options dialog

The walk through all sections

The walk through all keys



Save settings in application options dialog
With Storage library You can save settings of options dialog without any programming. Here is sequence of steps:
1. Put TrsPropSaver component to the application options form.
2. Change TrsPropSaver.RootSection if necessary. To "Options" for sample.
3. Change TrsPropSaver.WhenSave to wsManual.
4. Select property of other controls that need to be saved in TrsPropSaver dialog.
5. Now code for application options dialog call may be as shown below:

procedure TFormMain.actOptionsExecute(Sender: TObject);
var
  F: TFormOptions;
begin
  F := TFormOptions.Create(Self);
  if F.ShowModal=mrOk then begin
    // All changes is saved if user click 'OK' in dialog 
    F.rsPropSaver1.SaveValues; 
  end;
  F.Free;
end;
The Delphi4/5/6/7 demo project download (3kb)


The walk through all sections
Starting from version 3.12 of Storage library TrsStorage component has a methods SectionFirst, SectionNext, SectionPrior, SectionLast for walk through all sections. You can use its as shown below
  {Walk forward}
  if rsStorage1.SectionFirst>=0 then
    repeat
      {You can get information about current Section
       from TrsStorage.SectionWrapper}
      with ListView1.Items.Add do begin
        Caption := rsStorage1.SectionWrapper.Name;
        SubItems.Add(rsStorage1.SectionWrapper.FullName);
        SubItems.Add(IntToStr(rsStorage1.SectionWrapper.Level));
      end;
    until rsStorage1.SectionNext<0;

  {Walk backward}
  if rsStorage1.SectionLast>=0 then
    repeat
      {You can get information about current Section
       from TrsStorage.SectionWrapper}
      with ListView1.Items.Add do begin
        Caption := rsStorage1.SectionWrapper.Name;
        SubItems.Add(rsStorage1.SectionWrapper.FullName);
        SubItems.Add(IntToStr(rsStorage1.SectionWrapper.Level));
      end;
    until rsStorage1.SectionPrior<0;
The Delphi4/5/6/7 demo project download (11kb)


The walk through all keys
Starting from version 3.05 of Storage library TrsStorage component has a methods KeyFirst, KeyNext, KeyPrior, KeyLast for walk through all keys. You can use its as shown below
  {Walk forward}
  if rsStorage1.KeyFirst>=0 then
    repeat
      {You can get information about current Key
       from TrsStorage.KeyWrapper}
      with ListView1.Items.Add do begin
        Caption := rsStorage1.KeyWrapper.Name;
        SubItems.Add(rsStorage1.KeyWrapper.SectionFullName);
        SubItems.Add(IntToStr(rsStorage1.KeyWrapper.KeyType));
      end;
    until rsStorage1.KeyNext<0;

  {Walk backward}
  if rsStorage1.KeyLast>=0 then
    repeat
      {You can get information about current Key
       from TrsStorage.KeyWrapper}
      with ListView1.Items.Add do begin
        Caption := rsStorage1.KeyWrapper.Name;
        SubItems.Add(rsStorage1.KeyWrapper.SectionFullName);
        SubItems.Add(IntToStr(rsStorage1.KeyWrapper.KeyType));
      end;
    until rsStorage1.KeyPrior<0;
The Delphi4/5/6/7 demo project download (11kb)



Components ] [ Programs ] [ Articles ] [ Links ] [ Contacts ]


Copyright © 2000-2016 DeepSoftware.com All Rights reserved.
Terms of Use ] [ Privacy Statement ]