Just my 2c - although I probably got paid more than this to write a reply ;-)
Alister Christie Computers for People Phone: 04 471 1849 / Fax: 04 471 1266 PO Box 13085 Johnsonville Wellington
Neven MacEwan wrote:
Alistair
Firstly, why use INI files?, and why use Windows INI File functions? (god these date back to WIN.INI) where sychronisation of the INI Files was necesarry
I use XML to store config info (using OpenXML), stores anything in a structured manner and is simple to eunderstand and easy to edit
IMHO
Neven
----- Original Message ----- From: "Alistair George" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 26, 2004 9:16 AM
Subject: [DUG] A bit of coding for OOP experts.
Hi all. My preference has always been INI files over registry entries. Here is a
very useful component.
Unfortunately, it cant save checklistbox information. I tried unsuccessfully to save these items by using a GetPropInfo search
value of 'Items'
which brings up the component, but not the internal values eg
Checklistbox1.checked[0].
Cant seem to work my way through this one, anyone got any ideas?
Here is what I have been playing with: var prop: PPropInfo; Tstring:string;
prop := GetPropInfo(Owner.Components[i].ClassInfo, 'Items'); //Get
all Strings Items
Tstring:= lowercase(Owner.Components[i].ClassName); //Get
the base class name
if (prop <> nil) and (pos('checklistbox',Tstring)>0) then
//Ascertain its a checklistbox
Then here is the problem area:
with Owner.Components[i].Name as Tchecklistbox do //Throws a compile
error
begin J:= Items.Count-1;
Due to the component not knowing about the Owner, it may not be possible?
Then I would iterate through the checked items, and save the INI, which
would be used in below:
INIVAL : Save and Load fields values from INI file.
This small component when placed in a form Save and Load automatically
the
properties Text, Value and Checked of every the components of the
form.
I use it for remember configuration items.
If you want the source give me a yell.
procedure TIniVal.Save; var ini: TIniFile; prop : PPropInfo; i: Integer; begin ini := TIniFile.Create(GetName); try for i := 0 to Owner.ComponentCount -1 do begin prop := GetPropInfo(Owner.Components[i].ClassInfo, 'Text'); if (prop <> nil) and (prop^.PropType^.Kind in
[tkString,tkLString,tkWString]) then
ini.WriteString(Owner.Name,Owner.Components[i].Name,GetStrProp(Owner.Compone nts[i], prop));
prop := GetPropInfo(Owner.Components[i].ClassInfo, 'Value'); if (prop <> nil) and (prop^.PropType^.Kind in
[tkString,tkLString,tkWString]) then
ini.WriteString(Owner.Name,Owner.Components[i].Name,GetStrProp(Owner.Compone nts[i], prop));
if (prop <> nil) and (prop^.PropType^.Kind = tkInteger) then
ini.WriteInteger(Owner.Name,Owner.Components[i].Name,GetOrdProp(Owner.Compon ents[i], prop));
prop := GetPropInfo(Owner.Components[i].ClassInfo, 'Checked'); if (prop <> nil) then
ini.WriteBool(Owner.Name,Owner.Components[i].Name,Boolean(GetOrdProp(Owner.C omponents[i], prop)));
end; finally ini.Free; end;
end;
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
