Search code examples
delphilayoutdocking

DockManager LoadFromStream not working


I'm creating 5 forms and docking them to a panel called DockTarget during run time using something like

procedure TManager.InitChild;
begin
    Child := TChildWindow.Create(Self);
    Child.ManualDock(DockTarget);
end;

after all five children are created and docked I'm calling

Settings.DockSettings.Seek(0,soBeginning);
DockTarget.DockManager.LoadFromStream(Settings.DockSettings);

but it doesn't seem to do anything, all children are dock and no matter what I do to the layout before closing the form it opens exactly the same as if LoadFromStream wasn't there.

Settings.DockSettings is a TMemoryStream Loaded from file when the settings are created earlier.

and onFormClose I have

DockTarget.DockManager.SaveToStream(Settings.DockSettings);
Settings.Save;

Any idea's why the layout isn't being restored? Or an alternative I could use for saving/loading a docked layout?


Solution

  • Simply need to clear the in memory stream before saving, otherwise I ended up with 2 sets of Docking data of which only the first one was loaded.