1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31:
| uses Classes, StdCtrls, SysUtils, IniFiles;
procedure SaveLabels(const obComponent : TComponent; const sFileName : String); var iIndex : Integer; obIniFile : TIniFile; obLabel : TLabel; begin obIniFile := TIniFile.Create(sFileName);
try
for iIndex := 0 to obComponent.ComponentCount-1 do begin if (obComponent.Components[iIndex] is TLabel) then begin obLabel := (obComponent.Components[iIndex] as TLabel);
obIniFile.WriteString ('Label' + IntToStr(iIndex), 'Caption', obLabel.Caption); obIniFile.WriteInteger('Label' + IntToStr(iIndex), 'Top', obLabel.Top); obIniFile.WriteInteger('Label' + IntToStr(iIndex), 'Left', obLabel.Left); end; // if ... is TLabel end; // for iIndex
finally // try - finally stellt sicher, dass <obIniFile> auch wieder freigegeben wird obIniFile.Free; end; // try - finally end; |