[Lazarus] Examples of IniPropStorage?

Luca Olivetti luca at wetron.es
Sun Feb 22 13:26:22 CET 2009


En/na David W Noon ha escrit:
> On Sat, 2009-02-21 at 19:06 +0100, Luca Olivetti wrote:
> 
>> En/na David W Noon ha escrit:
> [snip]
>>> If there are none, could somebody please give me a quick sample they
>>> have knocked up for their own use? Thanks in advance.
>> Drop a TIniPropStorage on the form, let's call it FormStorage.
>> Put all properties you want to preserve in the form SessionProperties 
>> (there's a nice dialog to add what you want).
>> If you know beforehand the location of the .ini file, just set it in the 
>> TIniPropstorage at design time, otherwise assign it in FormCreate.
>> Also in FormCreate call restore.
>> When you want to save, just call save, e.g.:
>>
>> procedure TSettingsForm.FormCreate(Sender: TObject);
>> begin
>>    FormStorage.IniFileName:=SettingsFilename;
>>    FormStorage.Restore;
>> end;
>>
>> procedure TFormAjustes.SaveButtonClick(Sender: TObject);
>> begin
>>    FormStorage.Save;
>> end;
> 
> Thanks for that, Luca. The code is putting me in the right direction.
> 
> Now, how do I actually extract key/value pairs from it and store
> key/value pairs into it? 

I don't know, and actually I don't really care: I just set the values I 
want to save/restore using SessionProperties of the form.


> The only property I have found that looks
> likely is the StoredValues collection, but this is too kludgey to be
> true, e.g.:
> 
>    Name_field.Text := Ini_props.StoredValues['Name'].Value;

Why don't you just put Name_field.Text in SessionProperties?

Bye
-- 
Luca



More information about the Lazarus mailing list