Hoa hectorgn y bienvenido a Club Delphi
Como a todos los que se inician te invitamos a que leas nuestra
guía de estilo.
Vamos a tu consulta...
Utilizando archivo .INI:
Código Delphi
[-]
...
uses IniFiles;
procedure TForm1.FormCreate(Sender: TObject);
const Alto= 768;
Ancho= 1366;
begin
MRut.AdaptarResolucion(frMain, Alto, Ancho);
with TIniFile.Create(ExtractFilePath(Application.ExeName)+'TodoRubro.INI')do
try
Left := ReadInteger('FormLeft','Left',0);
Top := ReadInteger('FormTop','Top',0);
Height:= ReadInteger('FormHeight','Height',768);
Width := ReadInteger('FormWidth','Width',1024);
finally
Free;
end;
end;
...
procedure TForm1.FormDestroy(Sender: TObject);
begin
with TIniFile.Create(ExtractFilePath(Application.ExeName)+'TodoRubro.INI')do
try
WriteInteger('FormLeft','Left',Left);
WriteInteger('FormTop','Top',Top);
WriteInteger('FormHeight','Height',Height);
WriteInteger('FormWidth','Width',Width);
finally
Free;
end;
end;
Utilizando el registro de windows:
Código Delphi
[-]
...
uses Registry;
procedure TForm1.FormCreate(Sender: TObject);
var
R: TRegistry;
begin
with TRegistry.Create do
try
RootKey:= HKEY_CURRENT_USER;
if OpenKey('MiAplicacion', false) then
begin
Left:= ReadInteger('FormLeft');
Top:= ReadInteger('FormTop');
Height:= ReadInteger('FormHeight');
Width:= ReadInteger('FormWidth');
end;
finally
CloseKey;
Free;
end;
end;
...
procedure TForm1.FormDestroy(Sender: TObject);
begin
with TRegistry.Create do
try
RootKey:= HKEY_CURRENT_USER;
OpenKey('MiAplicacion', True);
WriteInteger('FormLeft',Left);
WriteInteger('FormTop',Top);
WriteInteger('FormHeight',Height);
WriteInteger('FormWidth',Width);
finally
CloseKey;
Free;
end;
end;
Para ampliar mas revisá estos enlaces:
Saludos.