Skip to content

TTMSFNCAppFormPersist

TTMSFNCAppFormPersist is a non-visual component to save the on-screen position and dimensions of a form. If the component is added at design-time it will automatically load the settings at run-time when the form is shown and it will automatically save the settings when the form is closed.

It’s also possible to call LoadFormSettings and SaveFormSettings to controll the loading and saving process programatically.

procedure TForm1.restoreBtnClick(Sender: TObject);
var
  afp: TTMSFNCAppFormPersist;
begin
  afp := TTMSFNCAppFormPersist.Create(Self);
  afp.FileName := './temp_settings.ini';
  afp.LoadFormSettings;
  afp.Free;
end;

procedure TForm1.saveBtnClick(Sender: TObject);
var
  afp: TTMSFNCAppFormPersist;
begin
  afp := TTMSFNCAppFormPersist.Create(Self);
  afp.FileName := './temp_settings.ini';
  afp.SaveFormSettings;
  afp.Free;
end;

Properties

Property name Description
FileName: string Path to the .INI file.
SaveFileKey: string Key in the .INI file for the form settings. It defaults to the form name.
SavePosition: Boolean If set to True, the position of the window is saved.
SaveSize: Boolean If set to True the windows size is saved.
UseMachineName: Boolean If set to True, the machine name is added to the key.
UseUsername: Boolean If set to True the username is added to the key.

Methods

Method name Description
LoadFormSettings Load the form settings from the FileName.ini file.
SaveFormSettings Save the form settings to the FileName.ini file.