1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
| Clear All
Public oForm
oForm = Createobject('MainMenu')
oForm.Show()
Define Class mainMenu As Form
Height = 600
Width = 800
Procedure Init
This.Set_Up_Menu()
Endproc
Procedure Destroy
Clear Class ('clCommandGroup')
Endproc
Procedure Set_Up_Menu
* Method "Set_up_menu" in form "frmMainmenu"
Local ix, ixxx, lnButtonHeight, lnButtonWidth, lnRecCnt, lnContTop, lnContLeft, lnTopPart, ;
lcClick1, lcClick2, lcClick3, lcClick4, lcClick5, lcClick6, lcClick7, lcClick8, lcClick9
lnContTop = 200 && Top of container
lnContLeft = 500 && Left of container
* lnButtonHeight = 30 && Height of buttons
lnButtonWidth = 0 && Will become width of all butttons
lnBtwButtons = 15 && Distance between buttons as well as between buttons and top/bottom of commandgroup
lnTopPart = 60 && Distane between top of container and top of commandgroup
lcFrmBackColor = Rgb(211,223,254)
lcCntBackColor = Rgb(205,200,245)
lcCmgBackColor = Rgb(191,166,191)
lcCmdForeColor = Rgb(255,255,255)
lcCmdBackColor = Rgb(0,0,100)
lcLblForeColor = Rgb(0,0,0)
*
* CREATE CURSOR BUTTON GROUP
*
Create Cursor curCommandGroup (ButtonCaption c(25)) && Max 25 characters, max 9 menu options.
Insert Into curCommandGroup Values ('\<')
Insert Into curCommandGroup Values ('\<Applications')
Insert Into curCommandGroup Values ('\<')
Insert Into curCommandGroup Values ('\<')
Insert Into curCommandGroup Values ('\<Hardware')
Insert Into curCommandGroup Values ('\<')
Insert Into curCommandGroup Values ('\<')
Insert Into curCommandGroup Values ('\<Settings') && This must be next to the last menu option.
Insert Into curCommandGroup Values ('\<Exit') && This must be the last menu option.
* ============================ Code in click method ==========
TEXT TO lcClick1 && Code for 1st button above
MESSAGEBOX('Just any command. - 1')
ENDTEXT
* --------------------------------------------
TEXT TO lcClick2 && Code for 2nd button above
MESSAGEBOX('Just any command. - 2')
ENDTEXT
* --------------------------------------------
TEXT TO lcClick3 && Code for 3rd button above
MESSAGEBOX('Just any command. - 3')
ENDTEXT
* --------------------------------------------
TEXT TO lcClick4 && Code for 4th button above
CLEAR EVENTS
THISFORM.Release
ENDTEXT
* --------------------------------------------
TEXT TO lcClick5 && Code for 5th button above
MESSAGEBOX( [No commands here or later, because I only need 4 buttons in this menu] )
ENDTEXT
* --------------------------------------------
* ==============================================================================================
Thisform.Newobject('cntMenuContainer','Container') && Creating a container
Thisform.Newobject('lblAppdescr','Label') && Creating an application description label
Thisform.Newobject('lblCopyright','Label') && Creating a copyright label
Thisform.cntMenuContainer.Newobject('lblMainmenu','Label') && Creating Label
Thisform.cntMenuContainer.Newobject('linMainmenu','Line') && Creating Line
* ==============================================================================================
Store 0 To lnRecCnt
Scan For Len(Trim(ButtonCaption)) > 2
lnRecCnt = m.lnRecCnt + 1
Store Trim(ButtonCaption) To ( 'm.lcCaption'+Ltrim(Str(m.lnRecCnt)) )
Endscan
Local lcClassCode, lcCodeFile
lcClassCode = TwsMainMenu(m.lcClick1, m.lcClick2, m.lcClick3, m.lcClick4, ;
m.lcClick5, m.lcClick6, m.lcClick7, m.lcClick8, m.lcClick9, m.lnRecCnt)
lcCodeFile=Forcepath('MyClass.prg',Sys(2023))
Strtofile( m.lcClassCode, m.lcCodeFile)
Compile (m.lcCodeFile)
Thisform.cntMenuContainer.Newobject('cmgMenuGroup','clCommandGroup',m.lcCodeFile)
Thisform.cntMenuContainer.Visible = .T.
For ix = 1 To lnRecCnt
With Thisform.cntMenuContainer.cmgMenuGroup.Buttons[m.ix]
.Caption = Evaluate( 'm.lcCaption'+Ltrim(Str(m.ix)) )
.AutoSize = .T.
.ForeColor = m.lcCmdForeColor
.BackColor = m.lcCmdBackColor
.Top = ((m.ix - 1) * 1.5 * .Height) + m.lnBtwButtons
.Left = 10
lnButtonHeight = .Height
If m.lnButtonWidth < .Width
lnButtonWidth = .Width
Endif
.AutoSize = .F.
Endwith
Endfor
For ix = 1 To lnRecCnt
Thisform.cntMenuContainer.cmgMenuGroup.Buttons[m.ix].Width = lnButtonWidth && Setting (same) width for all buttons
Endfor
*
* SET VALUES FOR COMMANDGROUP
*
With Thisform.cntMenuContainer.cmgMenuGroup && CommandGroup
.BackColor = m.lcCmgBackColor
.Top = lnTopPart && From container top
.Left = 10 && From container left
.Height = (.ButtonCount * lnButtonHeight) + ((.ButtonCount + 1) * lnBtwButtons)
.Width = lnButtonWidth + 20
.SetAll('Visible',.T.)
.Visible = .T.
Endwith
*
* SET VALUES FOR CONTAINER, LABEL & LINE
*
With Thisform.cntMenuContainer && Container
.BackColor = m.lcCntBackColor
.Top = lnContTop && Container top
.Left = lnContLeft && Container left
.Height = .cmgMenuGroup.Height + 75 && Container height
.Width = .cmgMenuGroup.Width + 20 && Container width
.Visible = .T. && Container visible
*
With .lblMainmenu && Label ("MAIN MENU")
.Caption = 'MAIN MENU'
.BackStyle = 0
.ForeColor = m.lcLblForeColor
.FontSize = 12
.AutoSize = .T.
.Top = (lnTopPart /2) - (.Height/2)
.Left = (Thisform.cntMenuContainer.Width/2) - (.Width/2)
.Alignment = 2
.Visible = .T.
Endwith
*
With .linMainmenu && Line
.Top = 50
.Left = 0
.Height = 0
.Width = Thisform.cntMenuContainer.Width
.Visible = .T.
Endwith
Endwith
*
* SETTING VALUES FOR FORM LABELS (2)
*
With Thisform.lblAppdescr
.Caption = 'TERMINOLOGY WEB SEARCH'
.BackStyle = 0
.FontSize = 16
.AutoSize = .T.
.Top = lnContTop - 50
.Left = lnContLeft + (Thisform.cntMenuContainer.Width/2) - (.Width/2)
.Alignment = 2
.Visible = .T.
Endwith
*
With Thisform.lblCopyright
.Caption = '© Copyright TransManage Software 2010'
.BackStyle = 0
.FontSize = 8
.AutoSize = .T.
.Top = lnContTop + Thisform.cntMenuContainer.Height + 50
.Left = lnContLeft + (Thisform.cntMenuContainer.Width/2) - (.Width/2)
.Alignment = 2
.Visible = .T.
Endwith
Thisform.BackColor = m.lcFrmBackColor
Endproc
Enddefine |