Ver Mensaje Individual
  #7  
Antiguo 23-09-2004
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.289
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Es sencillo, incluso si buscas en la ayuda de delphi encontrarás ejemplos; De todas formas aquí te adjunto un pequeño código que puedes probar en un form, que lo que hace es guardar (en el close) y restaurar el estado (en el crete) de un form en un fichero INI utilizzando la clase TIniFile.

Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
var
  Status: Integer;
begin
  IniFile := TIniFile.Create (ChangeFileExt (
    Application.ExeName, '.ini'));
  {try to read a value and test if it exists}
  {Intenta leer el valor y comprueba si existe}
  Status := IniFile.ReadInteger ('MainForm', 'Status', 0);
  if Status <> 0 then
  begin
    {read position and size using current values as default}
    [Lee del fichero las posiciones usando valor por defecto]
    Top := IniFile.ReadInteger ('MainForm', 'Top', Top);
    Left := IniFile.ReadInteger ('MainForm', 'Left', Left);
    Width := IniFile.ReadInteger ('MainForm', 'Width', Width);
    Height := IniFile.ReadInteger ('MainForm', 'Height', Height);
    {set the minimized or maximized status}
    {Cambia el estado de la ventana}
    case Status of
      // 1: WindowState := wsNormal;
        //this is already the default
      2: WindowState := wsMinimized;
      3: WindowState := wsMaximized;
    end;
  end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
  Status: Integer;
begin
  if MessageDlg ('Grabar el estado actual del formulario?',
    mtConfirmation, [mbYes, mbNo], 0) = IdYes then
  begin
    Status := 1; // default   //valor por defecto
    case WindowState of
      wsNormal: begin
        {save position and size only if the state is normal}
        {Guarda la posición y tamaño sólo si el estado es normal}
        IniFile.WriteInteger ('MainForm', 'Top', Top);
        IniFile.WriteInteger ('MainForm', 'Left', Left);
        IniFile.WriteInteger ('MainForm', 'Width', Width);
        IniFile.WriteInteger ('MainForm', 'Height', Height);
      end;
      wsMinimized: Status := 2;
        {useless: this value is never set by VCL for the main form}
        {ëste valor nunca se coloca por la VCL para el form principal}
      wsMaximized: Status := 3;
    end;
    {check if the window is minimized, that is, if the form  is hidden and not active}
    {comppueba si la ventana está minimizada, oses si el form está oculto y no activo}
    if not Active then
      Status := 2;
    {write status information}
    {escribe la info. de estado}
    IniFile.WriteInteger ('MainForm', 'Status', Status);
  end;
  {in any case destroy the IniFile object}
  {en cualquier caso destruye el objeto IniFile}
  IniFile.Free;
end;
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.

Última edición por Neftali [Germán.Estévez] fecha: 23-09-2004 a las 10:22:01.
Responder Con Cita