Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Docking Sitelist Issue

I'm saving and restoring the docking layout on my application, but have come across an issue.  If I add a new dock panel to my project, it is not listed in the sitelist when read back from my XML confiig file.

Setting the added panel's panelvisible property doesn't dock it anywhere on screen.  I can't see it at all.  The only way I can start using it is to remove the sitelist from my xml file so the the design time layout is used.

What is the best way to deal with dock panels that the saved list doesn't know about ?

Comments

  • 7 Comments sorted by Votes Date Added
  • To make new panel visible you should dock it manually somewhere at application startup (or after layout loading) using TLMDDockSite.DockControl method. Or make it floating, using Panel.ManualFloat method. Logically, there no better way for new panels.
  • The panel is not new as such, just one that the old config file doesn't know about.

    I'll have a look at how I'm loading the layout and go from there.
  • Since layout loading reset all dock zones in the site, there no way to leave some non-loaded panels on their design-time places, because these "places" (zones) become non existing after layout loading. So, the only way is to dock panel manually or make it floating.

    I imagine the following way: after layout loading some panels become invisible, but application provides View menu, where user can click an item to show any of existing panels. So, menu item event handler should show panel as floating if the panel is not docked anywhere.
  • Posts: 0 Accepted Answer Vote Up0Vote Down
    FWIW, I save and load the layout in FinalBuilder, and I have docklayout version constant in the application, which I write to the layout files, if the version in the loaded file doesn't match then I do not load it, and immediately write out a new layout file. 

    function TMainForm.CheckDockLayoutFileVersion(const sFileName: string): boolean;
    var
      xmlDoc : IXMLDomDocument;
      applicationElement : IXMLDomElement;
      sDockLayoutVersion : string;
    begin
      result := False;

      xmlDoc := CoDOMDocument60.Create;
      if xmlDoc.load(sFileName) then
      begin
        applicationElement := xmlDoc.selectSingleNode('/sitelist/application') as IXMLDOMElement;

        if applicationElement <> nil then
        begin
          if applicationElement.getAttributeNode('docklayoutversion') <> nil then
            sDockLayoutVersion := applicationElement.getAttribute('docklayoutversion');

          if sDockLayoutVersion = dockLayoutVersion then
            Result := True;
        end;
      end;
    end;


    procedure TMainForm.DockPersisterWriteAppInfo(Sender: TObject; const Xml: ILMDXmlDocument);
    var
      elem: ILMDXmlElement;
      projectsElement : ILMDXmlElement;
      projectElement : ILMDXmlElement;
      i: Integer;
      WindowPlacement: TWindowPlacement;

    begin
      elem := Xml.DocumentElement.AppendElement('application');
      elem.SetAttr('docklayoutversion',dockLayoutVersion);
    ....

    I very rarely create new panels, but this deals with the issue. It's a pain if users lose their layout but not the end of the world. 
  • That seems like a reasonable solution.
  • Ok. This is another way to go, but users will encounter layout reset with every new version of layout file.
  • I ended up using the HasParent property of the dock panels in question.  If that is false, I use DockZone.FindZoneByClient find the dock zone of another panel I know is valid.  Then I use DockSite.DockControl to dock the parent-less panels.
Sign In or Register to comment.