Reputation: 1189
The INTACustomDockableForm
interface includes two methods: one for saving the window state and another for loading it.
I have implemented them as follows:
...
procedure TMyDockableForm.SaveWindowState(Desktop : TCustomIniFile; const Section : string; IsProject : Boolean);
var
wp : TWindowPlacement;
begin
wp.length := Sizeof(wp);
GetWindowPlacement(form.handle, @wp);
var
pos := wp.rcNormalPosition;
Desktop.WriteInteger(Section , 'Left', pos.Left);
Desktop.WriteInteger(Section , 'Top', pos.Top);
Desktop.WriteInteger(Section , 'Width', pos.Right - pos.Left);
Desktop.WriteInteger(Section , 'Height', pos.Bottom - pos.Top);
Desktop.WriteString(Section , 'State', GetEnumName(TypeInfo(TWindowState), Ord(form.WindowState)));
end;
procedure TMyDockableForm.LoadWindowState(Desktop : TCustomIniFile; const Section : string);
var
L, T, W, H : Integer;
begin
L := Desktop.ReadInteger(Section , 'Left', form.Left);
T := Desktop.ReadInteger(Section , 'Top', form.Top);
W := Desktop.ReadInteger(Section , 'Width', form.Width);
H := Desktop.ReadInteger(Section , 'Height', form.Height);
form.SetBounds(L, T, W, H);
form.Windowstate := TWindowState(GetEnumValue(TypeInfo(TWindowState), Desktop.ReadString(section, 'State', 'wsNormal')));
end;
The save and load functions will be triggered if I save the Standard Layout, switch to debug, and then load the Standard Layout again.
When I close Delphi, new entries will be written to $AppData\Roaming\Embarcadero\BDS\22.0\Default Layout.dst
, but load will not be executed when I start it again.
I would like my dockable form to open at the saved position upon startup too.
How can I achieve the desired behavior?
Upvotes: 0
Views: 170
Reputation: 1189
The two procedures mentioned above are not necessary to save the window state of an extension. As @UweRaabe commented, an instance of the form should be registered during initialisation:
(BorlandIDEServices as INTAServices).RegisterDockableForm(FInstance);
Upvotes: 0