How to store and read form size and position to/from INI file ------------------------------------------------------------- Set the Form's Position property to poDefault and use the following routines in form's OnCreate and OnDestroy events respectively. procedure tForm1.ReadPosFromINI(IniF: tIniFile); VAR WindowPlacement: tWindowPlacement; WState: byte; begin WState := IniF.ReadInteger(Self.Caption,'State',ord(wsNormal)); FillChar(WindowPlacement,SizeOf(WindowPlacement),#0); with WindowPlacement do begin length := SizeOf(WindowPlacement); case tWindowState(Wstate) of wsMaximized: showcmd := SW_SHOWMAXIMIZED; else showcmd := SW_SHOWNORMAL; end; rcNormalPosition.Left := IniF.ReadInteger(Self.Caption,'Left',left); rcNormalPosition.Top := IniF.ReadInteger(Self.Caption,'Top',top); rcNormalPosition.Right := IniF.ReadInteger(Self.Caption,'Right',left + width); rcNormalPosition.Bottom:= IniF.ReadInteger(Self.Caption,'Bottom',Top + Height); end; SetWindowPlacement(handle,@WindowPlacement); end; procedure tForm1.StorePosToINI(IniF: tIniFile); VAR WindowPlacement: tWindowPlacement; begin WindowPlacement.length := SizeOf(WindowPlacement); GetWindowPlacement(handle,@WindowPlacement); IniF.WriteInteger(Self.Caption,'State',ord(WindowState)); With WindowPlacement do begin IniF.WriteInteger(Self.Caption,'Left', rcNormalPosition.Left); IniF.WriteInteger(Self.Caption,'Top', rcNormalPosition.Top); IniF.WriteInteger(Self.Caption,'Right', rcNormalPosition.Right); IniF.WriteInteger(Self.Caption,'Bottom', rcNormalPosition.Bottom); end end;