Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 31-05-2013
Eze32 Eze32 is offline
Registrado
NULL
 
Registrado: may 2013
Posts: 3
Poder: 0
Eze32 Va por buen camino
Ayuda con archivos binarios usando TFileStream

Hola Necesito hacer el un porgrama donde guarde en un archivo binario mediante TFileStream la posicion en donde esta quedo por ultimas ves la ventana, y el ancho y largo de la misma, pero al codificarlo me da el siguiente error:

[Pascal Error] Ejercicio3.pas(41): E2036 Variable required
[Pascal Error] Ejercicio3.pas(42): E2036 Variable required
[Pascal Error] Ejercicio3.pas(65): E2197 Constant object cannot be passed as var parameter
[Pascal Error] Ejercicio3.pas(66): E2197 Constant object cannot be passed as var parameter
[Pascal Error] Ejercicio3.pas(67): E2197 Constant object cannot be passed as var parameter
[Pascal Error] Ejercicio3.pas(68): E2197 Constant object cannot be passed as var parameter
[Pascal Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Ejercicio3.pas'

Les agradeceria mucho si me dicen como hacer para usar bien archivos binarios en este programa.Muchas Gracias

El codigo es el siguiente:

Código:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
   Ini : TiniFile;
   Binario : TFileStream;
begin
   //Con Archivo Ini
  // Ini := TiniFile.Create(ExtractFilePath(Application.ExeName) + 'Config.ini');
   //Ini.WriteInteger('DIMESION','Ancho',Width);
   //Ini.WriteInteger('DIMESION','Alto',Height);
   //Ini.WriteInteger('Posicion','Izquierdo',Left);
   //Ini.WriteInteger('Posicion','Superior',top);
   //Ini.free;

   //Con Archivo Binario
   Binario := TFileStream.Create(ExtractFilePath(Application.ExeName) + 'Config.dat',fmCreate);
   Binario.Write(Left,sizeof(integer));
   Binario.Write(Top,sizeof(integer));
   Binario.Write(Width,sizeof(integer));
   Binario.Write(Height,sizeof(integer));
   Binario.Free;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  Ini : TiniFile;
  Binario : TFileStream;
begin
  //Con Archivo Ini
  //Ini := TiniFile.Create(ExtractFilePath(Application.ExeName) + 'Config.ini');
  //Width := Ini.ReadInteger('DIMESION','Ancho',0);
  //Height := Ini.ReadInteger('DIMESION','Alto',0);
  //Left := Ini.ReadInteger('Posicion','Izquierdo',0);
  //Top := Ini.ReadInteger('Posicion','Superior',0);
  //Ini.free;

  //Con Archivo Binario
  Binario := TFileStream.Create(ExtractFilePath(Application.ExeName) + 'Config.dat',fmOpenRead);
  while Binario.Position < Binario.Size do
  begin
   Left := Binario.Read(Left ,sizeof(integer));
   Top := Binario.Read(Top ,sizeof(integer));
   Width :=Binario.Read(Width ,sizeof(integer));
   Height := Binario.Read(Height ,sizeof(integer));
  end;

  Binario.Free;
end;
Responder Con Cita
  #2  
Antiguo 31-05-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Eze32 , bienvenido a Club Delphi

Como a todos los ingresan te invitamos a que leas nuestra guía de estilo.

Código Delphi [-]
...
procedure TForm1.FormCreate(Sender: TObject);
var
  l,t,w,h: Integer;
begin
  with TFileStream.Create(ExtractFilePath(Application.ExeName)+'Config.dat', fmOpenRead) do
  try
    Seek(0, soFromBeginning);
    Read(l, SizeOf(integer));
    Read(t, SizeOf(integer));
    Read(w, SizeOf(integer));
    Read(h, SizeOf(integer));
    Left   := l;
    Top    := t;
    Width  := w;
    Height := h
  finally
    Free
  end;
end;

...

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  with TFileStream.Create(ExtractFilePath(Application.ExeName)+'Config.dat', fmCreate) do
  try
    Write(Left, SizeOf(integer));
    Write(Top, SizeOf(integer));
    Write(Width, SizeOf(integer));
    Write(Height, SizeOf(integer))
  finally
    Free
  end;
end;

...

Saludos.

Edito: ¿ No te resulta mas sencillo hacerlo con el registro de windows ?
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 31-05-2013 a las 17:22:32.
Responder Con Cita
  #3  
Antiguo 04-06-2013
Eze32 Eze32 is offline
Registrado
NULL
 
Registrado: may 2013
Posts: 3
Poder: 0
Eze32 Va por buen camino
Gracias por la respuesta me sirvio mucho la ayuda.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Manejo de Archivos con TFileStream nlsgarcia Varios 6 02-09-2011 02:26:36
Necesito ayuda con el manejo de archivos usando delphi 7 mauser1985 Impresión 40 14-07-2008 00:14:00
Necesito ayuda con el manejo de archivos usando delphi 7 mauser1985 Varios 1 13-07-2008 00:08:44
archivos binarios kazcote Varios 5 05-12-2005 04:02:35
ayuda programa con archivos binarios nahuel Varios 4 25-01-2004 17:55:20


La franja horaria es GMT +2. Ahora son las 01:55:12.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi