source: trunk/Forms/FormMain.pas

Last change on this file was 32, checked in by chronos, 6 months ago
  • Modified: Removed U prefix from units names.
  • Modified: Use TFormEx for all forms.
File size: 2.5 KB
Line 
1unit FormMain;
2
3interface
4
5uses
6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
7 ComCtrls, FormTables, FormEx;
8
9type
10
11 { TFormMain }
12
13 TFormMain = class(TFormEx)
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
44implementation
45
46{$R *.lfm}
47
48uses
49 Core;
50
51{ TFormMain }
52
53procedure TFormMain.FormActivate(Sender: TObject);
54begin
55 Core.Core.Init;
56 // TODO: Toolbar height is incorrectly calculated
57 ToolBar1.ButtonHeight := ToolBar1.Height;
58end;
59
60procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
61begin
62 Core.Core.Done;
63end;
64
65procedure TFormMain.FormCreate(Sender: TObject);
66begin
67 FormTables := TFormTables.Create(nil);
68end;
69
70procedure TFormMain.FormDestroy(Sender: TObject);
71begin
72 FreeAndNil(FormTables);
73end;
74
75procedure TFormMain.FormShow(Sender: TObject);
76begin
77 SetToolbarHints;
78 DockInit;
79end;
80
81procedure TFormMain.DockInit;
82begin
83 FormTables.ManualDock(Self, nil, alClient);
84 FormTables.Align := alClient;
85 FormTables.Show;
86end;
87
88procedure TFormMain.UpdateInterface;
89var
90 NewCaption: string;
91begin
92 NewCaption := Application.Title;
93 if Assigned(Core.Core.DbClient) then
94 NewCaption := Core.Core.DbClient.ConnectProfile.Name + ' - ' + NewCaption;
95 Caption := NewCaption;
96 FormTables.UpdateInterface;
97end;
98
99procedure TFormMain.SetToolbarHints;
100var
101 I: Integer;
102 J: Integer;
103 Control: TControl;
104begin
105 for J := 0 to CoolBar1.ControlCount - 1 do begin
106 Control := CoolBar1.Controls[J];
107 if Control is TToolBar then begin
108 for I := 0 to TToolBar(Control).ButtonCount - 1 do begin
109 TToolBar(Control).Buttons[I].ShowHint := True;
110 TToolBar(Control).Buttons[I].Hint := TToolBar(Control).Buttons[I].Caption;
111 end;
112 end;
113 end;
114end;
115
116end.
117
Note: See TracBrowser for help on using the repository browser.