Howdy, Stranger!

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

In this Discussion

Saving last status of panels

Hi,

I have a very simple delphi 2010 form application containing a dock manager, dock site en 1 panel. At FormShow I try to restore the last status, at FormDestroy I want to save it. This only works as long as my panel is docked. If it's floating during program close its state is not saved. It even doesn't appear in the xml-file anymore.
I also want to add some runtime created panels, but they aren't saved in the last status xml either. What am I missing?

Below is the source code of my project.

Regards and thanks,
Gertjan


unit MyDemo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, LMDDckSite;

type
  TForm1 = class(TForm)
    LMDDockSite1: TLMDDockSite;
    LMDDockManager1: TLMDDockManager;
    LMDDockPanel1: TLMDDockPanel;
    procedure FormShow(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  APanel : TLMDDockPanel;
begin
  APanel          := TLMDDockPanel.Create(self);
  APanel.Parent   := LMDDockSite1;
  APanel.Caption  := 'Runtime created dock';
  LMDDockSite1.DockControl(APanel,nil,alLeft);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  LMDDockManager1.SaveToFile('c:\test\state.xml');
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  if FileExists('c:\test\state.xml') then
    LMDDockManager1.LoadFromFile('c:\test\state.xml');
end;

end.

Comments

  • 3 Comments sorted by Votes Date Added
  • Posts: 0 Accepted Answer Vote Up0Vote Down
    Hi,

    1) Your runtime panel is not saved because it has no name. Some identifier (string) should be saved into XML to aloow later to find a panel while loading layout. So, you can specify usual Name property value or, if you don't want to use Delphi Name property, you can write event handlers for manager's OnGetComp and OnGetCompId events to implement custom idetifiers association.

    2) Your floating sites are not stored because at the point when you  save layout, they are already destroyed. All forms, including floating forms are children of global standard Application object. and while application termination it destroys forms one by one. Main form is destroyed last. 
    So, do not use OnDestroy to save layout, use OnClose instead.



  • That's lot, that solved my problem!
    Regards,
    Gertjan
Sign In or Register to comment.