Jump to content


Photo

LoadFromRegistry suggestion


  • Please log in to reply
3 replies to this topic

#1 Jordan

Jordan
  • Members
  • 14 posts

Posted 14 July 2009 - 05:34 PM

If the LoadFromRegistry does not find the registry keys, it uses default values, and those values might override values established at design time (especially column visibility). It would be useful to have a "RegistryEntriesFound" function that could test the registry to determine whether a SaveToRegistry had already been performed, so that LoadFromRegistry could be skipped or aborted if previously saved information is not present.

For my application, I frequently have columns that are invisible, and if I perform a LoadFromRegistry prior to SaveToRegistry, I lose the invisibility status of those columns.

Using the "SectionExists" method of the tCustomIniFile might be an appropriate way to perform this test.

#2 Jordan

Jordan
  • Members
  • 14 posts

Posted 14 July 2009 - 05:54 PM

I tried this test code for the function I suggested and it worked fine for what I needed:

CODE
function tNXCustomGridControl.SavedDataExists(const KeyName: WideString;
                                              ID: string): boolean;
var
  IniFile: TRegistryIniFile;
begin
  try
    IniFile := TRegistryIniFile.Create(KeyName);
    Result := IniFile.SectionExists('Common' + ID);
  finally
    FreeAndNil(IniFile);
  end;
end;


#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 14 July 2009 - 10:22 PM

Hello Jordan,

Can you please use this function if not a problem, inside your unit. Thank you.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#4 Jordan

Jordan
  • Members
  • 14 posts

Posted 15 July 2009 - 03:20 AM

QUOTE (Boki (Berg) @ Jul 14 2009, 05:22 PM) <{POST_SNAPBACK}>
Hello Jordan,

Can you please use this function if not a problem, inside your unit. Thank you.

Best regards


No problem...it's working fine for me as described.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users