Ver Mensaje Individual
  #3  
Antiguo 07-02-2006
Avatar de xavinet
xavinet xavinet is offline
Miembro
 
Registrado: mar 2005
Posts: 41
Reputación: 0
xavinet Va por buen camino
coge papel, lapiz y apunta ;P

Hola noipa!

A lo mejor algo así ya te servirá:

Código Delphi [-]
procedure Guardar(NombreFichero : string);
var
  FicheroIni : TMemIniFile;
  i : Integer;
  Componente : TComponent;
begin
  FicheroIni:= TMemIniFile.Create(NombreFichero);
  try
    // recorres todos los componentes  
    for i := 0 to (ComponentCount - 1) do begin
      begin        
        Componente := Components[i]; // Componente actual
        // haces el tratamiento de los componentes y sus propiedades 
        // ves guardando en el fichero ini lo que te interese de cada componente
        FicheroIni.WriteString(...);
      end;   
    FicheroIni.UpdateFile;
  finally
    FicheroIni.Free;
  end;
end;  

procedure Recuperar(NombreFichero : string);
var
  FicheroIni : TMemIniFile; 
  Lista : TStringList; 
  Componente : TComponent;
  i : Integer;
begin
  FicheroIni := TMemIniFile.Create(NombreFichero);
  try
    Lista := TStringList.Create;
    try
      FicheroIni.ReadSections(Lista); // lista de todo lo guardado en el archivo.ini
      for index := 0 to ListaItems.Count - 1 do
        begin
          // lees todas la variables que hayas guardado
          FicheroIni.ReadString(...);
          // o
          FicheroIni.ReadInteger(...):
          // etc, segun te convenga
        end;
    finally
      if Assigned(Lista) then FreeAndNil(Lista);
    end;       
    for i := 0 to (ComponentCount - 1) do 
      begin        
        Componente := Components[i]; // Componente actual
        // haces el tratamiento de los componentes y sus propiedades 
      end;          
  finally
    FicheroIni.Free;
  end;
end;

suerte!

pd: el código es una pauta no una plantilla, habrá que currarselo un poco, lo siento ;P
pd: si no has trabajado nunca con componentes alomejor podría especificar un poco más, tu dirás
Responder Con Cita