Using AnchorDocking lazarus / 5-Lazarus Extra Components ---------------------------------------------------------------------- creaothceann · 2016-01-21 00:40 I have a main form and several helper forms, created automatically in the project.lpr file. At program start I want to attach the helper forms to the bottom of the main form so that they are in a TPageControl. After some reading (here and the example at components/anchordocking/miniide/miniide1.lpi) my code looks like this: Code: [Select]procedure TForm_Main.Form_OnCreate(Sender : TObject); begin DockMaster.OnShowOptions := @AnchorDockOptionsDlg.ShowAnchorDockOptions; DockMaster.MakeDockSite(Self, [akBottom], admrpChild, False); end; procedure TForm_Main.Form_OnShow(Sender : TObject); begin if (not _shown) then begin  // private variable         _shown := True;         DockMaster.MakeDockable(HelperForm1);         DockMaster.MakeDockable(HelperForm2); end; end; This creates the docking site on the main form and shows the helper forms with the docking header, and it's possible to drag'n'drop the forms onto the main form. It seems that I have to use the function DockMaster.ManualDock to do this with code. After countless random tries (wiki being extremely cryptic) I got this: Code: [Select]procedure TForm_Main.Form_OnShow(Sender : TObject); var     Site1 : TAnchorDockHostSite;         Site2 : TAnchorDockHostSite; begin if (not _shown) then begin         _shown := True;         // show forms         DockMaster.MakeDockable(HelperForm1);         DockMaster.MakeDockable(HelperForm2);         // attach them to main window         Site1 := DockMaster.GetAnchorSite(HelperForm1);         Site2 := DockMaster.GetAnchorSite(HelperForm2);         DockMaster.ManualDock(Site1, Self, alBottom, NIL);         DockMaster.ManualDock(Site2, Self, alClient, HelperForm1); end; end; This works (rather non-intuitively), but only as long as I leave at least one helper form attached to the main form. As soon as all have been dragged off, the main form's docking site seems nonexistent. Is there a way to fix that? My configuration: - 64-bit Win7 Ultimate SP1 - 64-bit Lazarus 1.6RC2, FPC3 PS: For the record, AnchorDockPkg has to be added to the program's uses-section after the Interfaces unit, otherwise there's a SIGSEV when the program is closed. EDIT: How can I close or hide one of the dockable helper forms? Form.Close and Form.Visible := False don't work. Do I really have to Free them? ---------------------------------------------------------------------- bastynator · 2016-07-03 18:33 Did you try to load the layout by a xml? That worked for me  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMainIDE.LoadLayout(Filename: string);var  XMLConfig: TXMLConfigStorage;begin  try    // load the xml config file    XMLConfig:=TXMLConfigStorage.Create(Filename,True);    try      // restore the layout      // this will close unneeded forms and call OnCreateControl for all needed      DockMaster.LoadLayoutFromConfig(XMLConfig,true);    finally      XMLConfig.Free;    end;  except    on E: Exception do begin      MessageDlg('Error',        'Error loading layout from file '+Filename+':'#13+E.Message,mtError,        [mbCancel],0);    end;  end;end;