source: DockManagement/Demo/UMainForm.pas

Last change on this file was 6, checked in by chronos, 13 years ago
  • Added: Some basic functionality for conjoined form support.
File size: 2.4 KB
Line 
1unit UMainForm;
2
3interface
4
5uses
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
9type
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
28var
29 MainForm: TMainForm;
30
31implementation
32
33{$R *.dfm}
34
35procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
36begin
37 //CustomDockManager.SaveToRegistry;
38end;
39
40procedure TMainForm.FormCreate(Sender: TObject);
41begin
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;
53end;
54
55procedure TMainForm.FormDestroy(Sender: TObject);
56begin
57 BaseDockPanel.Free;
58 CustomDockManager.Free;
59 Forms.Free;
60end;
61
62procedure TMainForm.FormShow(Sender: TObject);
63var
64 I: Integer;
65begin
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;
79end;
80
81function TMainForm.NewDockForm: TDockForm;
82begin
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);
90end;
91
92procedure TMainForm.Newform1Click(Sender: TObject);
93begin
94 Forms.Add(NewDockForm);
95end;
96
97end.
Note: See TracBrowser for help on using the repository browser.