SPECIAL OFFER        Order and save right now!
20% off with the 729824315 dicscount code for Ultimate Pack and any another product for Delphi from Greatis Programming!

⤷ Restore window to its last state

You can store the main parameters of your form in Registry. Resave them, when you close form, and you can restore them, if you create form again.

uses Registry;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  with TRegistry.Create do
  begin
   RootKey:=HKEY_LOCAL_MACHINE;
   if OpenKey('Greatis Software\Example\Form', True) then
   begin
     WriteInteger('Left', Form1.Left);
     WriteInteger('Top',  Form1.Top);
     WriteInteger('Width', Form1.Width);
     WriteInteger('Height', Form1.Height);
     case WindowState of
       wsMaximized: WriteInteger('State', 1);
       wsMinimized: WriteInteger('State', 2);
       wsNormal   : WriteInteger('State', 3);
     end;
   end
   else
     MessageDlg('Registry reading error', mtError, [mbOk], 0);
   CloseKey;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with TRegistry.Create do
  begin
    RootKey:=HKEY_LOCAL_MACHINE;
    if OpenKey('Greatis Software\Example\Form', False) then
    try
      Form1.Left:=ReadInteger('Left');
      Form1.Top:=ReadInteger('Top');
      Form1.Width:=ReadInteger('Width');
      Form1.Height:=ReadInteger('Height');
     case ReadInteger('State') of
       1: Form1.WindowState:=wsMaximized;
       2: Form1.WindowState:=wsMinimized;
       3: Form1.WindowState:=wsNormal;
     end;
    except
      MessageDlg('Can not go to handle', mtError, [mbOk], 0);
    end
    else
      MessageDlg('Registry reading error', mtError, [mbOk], 0);
    CloseKey;
  end;
end;
More for developers
Databases for Amazon Associates
Amazon Categories
Amazon Nodes