1 | unit UMainForm;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
|
---|
7 | Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, UDockForm, Vcl.Menus, UDockManagement, Generics.Collections;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TMainForm = class(TForm)
|
---|
11 | MainMenu1: TMainMenu;
|
---|
12 | Newform1: TMenuItem;
|
---|
13 | procedure Newform1Click(Sender: TObject);
|
---|
14 | procedure FormCreate(Sender: TObject);
|
---|
15 | procedure FormDestroy(Sender: TObject);
|
---|
16 | procedure FormShow(Sender: TObject);
|
---|
17 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
18 | private
|
---|
19 | RegistryKey: string;
|
---|
20 | function NewDockForm: TDockForm;
|
---|
21 | public
|
---|
22 | Forms: TObjectList<TForm>;
|
---|
23 | FormCounter: Integer;
|
---|
24 | BaseDockPanel: TDBaseDockPanel;
|
---|
25 | CustomDockManager: TDDockManager;
|
---|
26 | end;
|
---|
27 |
|
---|
28 | var
|
---|
29 | MainForm: TMainForm;
|
---|
30 |
|
---|
31 | implementation
|
---|
32 |
|
---|
33 | {$R *.dfm}
|
---|
34 |
|
---|
35 | procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
36 | begin
|
---|
37 | //CustomDockManager.SaveToRegistry;
|
---|
38 | end;
|
---|
39 |
|
---|
40 | procedure TMainForm.FormCreate(Sender: TObject);
|
---|
41 | begin
|
---|
42 | Forms := TObjectList<TForm>.Create;
|
---|
43 | CustomDockManager := TDDockManager.Create(Self);
|
---|
44 | CustomDockManager.RegistryKey := RegistryKey;
|
---|
45 | BaseDockPanel := TDBaseDockPanel.Create(Self);
|
---|
46 | with BaseDockPanel do begin
|
---|
47 | Parent := Self;
|
---|
48 | Align := alClient;
|
---|
49 | Visible := True;
|
---|
50 | BevelOuter := bvNone;
|
---|
51 | end;
|
---|
52 | CustomDockManager.BaseDockPanel := BaseDockPanel;
|
---|
53 | end;
|
---|
54 |
|
---|
55 | procedure TMainForm.FormDestroy(Sender: TObject);
|
---|
56 | begin
|
---|
57 | BaseDockPanel.Free;
|
---|
58 | CustomDockManager.Free;
|
---|
59 | Forms.Free;
|
---|
60 | end;
|
---|
61 |
|
---|
62 | procedure TMainForm.FormShow(Sender: TObject);
|
---|
63 | var
|
---|
64 | I: Integer;
|
---|
65 | begin
|
---|
66 | // Init dock init list
|
---|
67 | with CustomDockManager do begin
|
---|
68 | with BaseDockPanel do begin
|
---|
69 | PanelLeft.Tag := 150;
|
---|
70 | PanelTop.Tag := 150;
|
---|
71 | PanelRight.Tag := 100;
|
---|
72 | PanelBottom.Tag := 150;
|
---|
73 | end;
|
---|
74 | end;
|
---|
75 | //CustomDockManager.LoadFromRegistry
|
---|
76 | for I := 0 to 5 do begin
|
---|
77 | Forms.Add(NewDockForm);
|
---|
78 | end;
|
---|
79 | end;
|
---|
80 |
|
---|
81 | function TMainForm.NewDockForm: TDockForm;
|
---|
82 | begin
|
---|
83 | Inc(FormCounter);
|
---|
84 | Result := TDockForm.Create(MainForm);
|
---|
85 | Result.Memo1.Text := 'Form ' + IntToStr(FormCounter);
|
---|
86 | Result.Memo1.Align := alClient;
|
---|
87 | Result.Caption := 'Form ' + IntToStr(FormCounter);
|
---|
88 | Result.Show;
|
---|
89 | CustomDockManager.RegisterDockForm(Result, 200, 200, Result.Name, True);
|
---|
90 | end;
|
---|
91 |
|
---|
92 | procedure TMainForm.Newform1Click(Sender: TObject);
|
---|
93 | begin
|
---|
94 | Forms.Add(NewDockForm);
|
---|
95 | end;
|
---|
96 |
|
---|
97 | end.
|
---|