1 | unit UFormMain;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
|
---|
7 | ComCtrls, UFormTables;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TFormMain }
|
---|
12 |
|
---|
13 | TFormMain = class(TForm)
|
---|
14 | CoolBar1: TCoolBar;
|
---|
15 | MainMenu1: TMainMenu;
|
---|
16 | MenuItem1: TMenuItem;
|
---|
17 | MenuItem2: TMenuItem;
|
---|
18 | MenuItem3: TMenuItem;
|
---|
19 | MenuItem4: TMenuItem;
|
---|
20 | MenuItem5: TMenuItem;
|
---|
21 | MenuItem6: TMenuItem;
|
---|
22 | MenuItem7: TMenuItem;
|
---|
23 | MenuItem8: TMenuItem;
|
---|
24 | MenuItemPreferences: TMenuItem;
|
---|
25 | StatusBar1: TStatusBar;
|
---|
26 | ToolBar1: TToolBar;
|
---|
27 | ToolButton1: TToolButton;
|
---|
28 | ToolButton2: TToolButton;
|
---|
29 | ToolButton3: TToolButton;
|
---|
30 | procedure FormActivate(Sender: TObject);
|
---|
31 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
32 | procedure FormCreate(Sender: TObject);
|
---|
33 | procedure FormDestroy(Sender: TObject);
|
---|
34 | procedure FormShow(Sender: TObject);
|
---|
35 | private
|
---|
36 | procedure SetToolbarHints;
|
---|
37 | public
|
---|
38 | FormTables: TFormTables;
|
---|
39 | procedure DockInit;
|
---|
40 | procedure UpdateInterface;
|
---|
41 | end;
|
---|
42 |
|
---|
43 | var
|
---|
44 | FormMain: TFormMain;
|
---|
45 |
|
---|
46 |
|
---|
47 | implementation
|
---|
48 |
|
---|
49 | {$R *.lfm}
|
---|
50 |
|
---|
51 | uses
|
---|
52 | UCore;
|
---|
53 |
|
---|
54 | { TFormMain }
|
---|
55 |
|
---|
56 | procedure TFormMain.FormActivate(Sender: TObject);
|
---|
57 | begin
|
---|
58 | Core.Init;
|
---|
59 | // TODO: Toolbar height is incorrectly calculated
|
---|
60 | ToolBar1.ButtonHeight := ToolBar1.Height;
|
---|
61 | end;
|
---|
62 |
|
---|
63 | procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
64 | begin
|
---|
65 | Core.Done;
|
---|
66 | Core.PersistentForm1.Save(Self);
|
---|
67 | end;
|
---|
68 |
|
---|
69 | procedure TFormMain.FormCreate(Sender: TObject);
|
---|
70 | begin
|
---|
71 | FormTables := TFormTables.Create(nil);
|
---|
72 | end;
|
---|
73 |
|
---|
74 | procedure TFormMain.FormDestroy(Sender: TObject);
|
---|
75 | begin
|
---|
76 | FreeAndNil(FormTables);
|
---|
77 | end;
|
---|
78 |
|
---|
79 | procedure TFormMain.FormShow(Sender: TObject);
|
---|
80 | begin
|
---|
81 | Core.PersistentForm1.Load(Self, True);
|
---|
82 | SetToolbarHints;
|
---|
83 | DockInit;
|
---|
84 | end;
|
---|
85 |
|
---|
86 | procedure TFormMain.DockInit;
|
---|
87 | begin
|
---|
88 | FormTables.ManualDock(FormMain, nil, alClient);
|
---|
89 | FormTables.Align := alClient;
|
---|
90 | FormTables.Show;
|
---|
91 | end;
|
---|
92 |
|
---|
93 | procedure TFormMain.UpdateInterface;
|
---|
94 | var
|
---|
95 | NewCaption: string;
|
---|
96 | begin
|
---|
97 | NewCaption := Application.Title;
|
---|
98 | if Assigned(Core.DbClient) then
|
---|
99 | NewCaption := Core.DbClient.ConnectProfile.Name + ' - ' + NewCaption;
|
---|
100 | FormMain.Caption := NewCaption;
|
---|
101 | FormTables.UpdateInterface;
|
---|
102 | end;
|
---|
103 |
|
---|
104 | procedure TFormMain.SetToolbarHints;
|
---|
105 | var
|
---|
106 | I: Integer;
|
---|
107 | J: Integer;
|
---|
108 | Control: TControl;
|
---|
109 | begin
|
---|
110 | for J := 0 to CoolBar1.ControlCount - 1 do begin
|
---|
111 | Control := CoolBar1.Controls[J];
|
---|
112 | if Control is TToolBar then begin
|
---|
113 | for I := 0 to TToolBar(Control).ButtonCount - 1 do begin
|
---|
114 | TToolBar(Control).Buttons[I].ShowHint := True;
|
---|
115 | TToolBar(Control).Buttons[I].Hint := TToolBar(Control).Buttons[I].Caption;
|
---|
116 | end;
|
---|
117 | end;
|
---|
118 | end;
|
---|
119 | end;
|
---|
120 |
|
---|
121 | end.
|
---|
122 |
|
---|