delphiconstructorcomponents

In Delphi, how do you assign a component's property values before creating an app's main form?


TMS's FormSize component saves aForm's size and position in an .ini file. This file's path is stored in the component's SaveName property. I would like to assign FormSize.SaveName to a file in the user's AppData folder. I can find the AppData path in my source code.

Does anyone know where (in my code) I assign the AppData path to FormSize.SaveName? I am thinking the FormSize component is created, and a default SaveName initialized, BEFORE aForm is created. In other words, FormSize loads the config file BEFORE aForm's FormCreate event fires; assigning a value to FormSize.SaveName during aForm.FormCreate is too late.

Thanks, as always.


Solution

  • The adjustment of the form is done in the Loaded method of TFormSize, not when you change the SaveName property (although it has been read from the DFM before).

    If you set the properties SavePosition and SaveSize to false during designtime, there will nothing be loaded at runtime. In that case you can manually load and save the settings at a convenient place in your code by calling LoadFormSettings and SaveFormSettings.