Howdy, Stranger!

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

In this Discussion

Floating dock panels don't appear in panel count

When closing my program I create a list of open files so they can be reloaded on restart.  
However, when there are floating document panels they don't appear in the panels list.
This is my code for listing the open files:

function TfmIDEMain.ListOpenFiles(FileList: TStrings): integer;
Var idx: Integer;
    pnl: TLMDDockPanel;
    PageType: TIDEPageType;
    pInfo: TPageInfo;
begin
  for idx := 0 to dsMain.PanelCount -1 do begin
    pnl := dsMain.Panels[idx];
    if pnl.ClientKind <> dkDocument then
      Continue;
    PageType := TIDEPageType(Pnl.Tag);
    case PageType of
      ptEditor: pInfo := TfmEditor(pnl.Controls[0]).PageInfo;///.FileName;
      ptPDF:    pInfo := TfmPDFPage(pnl.Controls[0]).PageInfo;//.FileName;
    end;
    if (Length(pInfo.FileName) > 0) and (Not AnsiContainsText(pInfo.Filename, 'untitled')) then
      FileList.AddObject(pInfo.Filename, pointer(pInfo.Modified));
  end;
  Result := FileList.Count;
end;

As you can see I run through all the panels and if they are document panels save their filename.
How can I include floating panels in this list?  I don't need their state because they will be reloaded as docked tabs on restarting.
Tagged:

Comments

  • 1 Comment sorted by Votes Date Added
  • DockingSite provides a way to ietrate only docked inside it panels. Floating panels are actually docked in their own "floating" sites. The easy way to iterate all panels is to use it's owner's Components and ComponentCount properties. The owner of a panel is specified as AOwner parameter of panel's constructor. Most often the owner is the main form. 

    own := MyMainForm;
    for i := 0 to own.ComponentCount - 1 do
    begin
      if own.Components[i] is TLMDDockPanel then
        DoSomething(own.Components[i] as TLMDDockPanel);
    end;

    Another way is to keep your own list of panels.
Sign In or Register to comment.