-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.frm
482 lines (432 loc) · 13.9 KB
/
Main.frm
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
VERSION 5.00
Begin VB.Form frmMain
BorderStyle = 3 'Fixed Dialog
ClientHeight = 5415
ClientLeft = 45
ClientTop = 435
ClientWidth = 4110
Icon = "Main.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5415
ScaleWidth = 4110
ShowInTaskbar = 0 'False
Visible = 0 'False
Begin VBScroll.XPFrame xfrCtrlKey
Height = 2055
Left = 120
TabIndex = 10
Top = 1920
Width = 4080
_ExtentX = 7197
_ExtentY = 3625
Caption = "Ctrl key"
Begin VB.OptionButton optCtrlKey
Caption = "switch opened project windows"
Height = 255
Index = 3
Left = 120
TabIndex = 15
Top = 1680
Width = 3135
End
Begin VB.OptionButton optCtrlKey
Caption = "scroll procedures (code view)"
Height = 255
Index = 2
Left = 120
TabIndex = 14
Top = 1320
Width = 3135
End
Begin VB.OptionButton optCtrlKey
Caption = "perform horizontal scrolling"
Height = 255
Index = 1
Left = 120
TabIndex = 13
Top = 960
Width = 3135
End
Begin VB.OptionButton optCtrlKey
Caption = "ignore keystroke"
Height = 255
Index = 0
Left = 120
TabIndex = 12
Top = 600
Width = 3135
End
Begin VB.Image imgCtrlKey
Height = 480
Left = 3360
Picture = "Main.frx":1CFA
Top = 240
Width = 480
End
Begin VB.Label lblCtrlKey
AutoSize = -1 'True
Caption = "When Shift key is pressed:"
Height = 180
Left = 120
TabIndex = 11
Top = 240
Width = 2340
End
End
Begin VB.CommandButton cmdOk
Caption = "OK"
Default = -1 'True
Height = 375
Left = 1440
TabIndex = 21
Top = 4920
Width = 975
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "Cancel"
Height = 375
Left = 2520
TabIndex = 22
Top = 4920
Width = 975
End
Begin VBScroll.XPFrame xfrStartup
Height = 615
Left = 120
TabIndex = 16
Top = 4080
Width = 4080
_ExtentX = 7197
_ExtentY = 1085
Caption = "Startup"
Begin VB.OptionButton optCurrentUser
Caption = "Current user"
Height = 255
Left = 1320
TabIndex = 18
Top = 240
Width = 1455
End
Begin VB.OptionButton optAllUsers
Caption = "All users"
Height = 255
Left = 120
TabIndex = 17
Top = 240
Width = 1215
End
Begin VB.OptionButton optManual
Caption = "Manual"
Height = 255
Left = 2760
TabIndex = 19
Top = 240
Width = 855
End
End
Begin VBScroll.XPFrame xfrWheel
Height = 1695
Left = 120
TabIndex = 0
Top = 120
Width = 4080
_ExtentX = 7197
_ExtentY = 2990
Caption = "Wheel"
Begin VB.ComboBox cmbAction
Height = 315
ItemData = "Main.frx":25C4
Left = 1920
List = "Main.frx":25CB
Style = 2 'Dropdown List
TabIndex = 9
Top = 1260
Width = 1335
End
Begin VB.OptionButton optScrollPage
Height = 255
Left = 120
TabIndex = 6
Top = 960
Width = 255
End
Begin VB.OptionButton optScrollLines
Height = 255
Left = 120
TabIndex = 2
Top = 600
Width = 255
End
Begin VB.VScrollBar sclLines
Height = 220
Left = 810
Max = 99
Min = 1
TabIndex = 4
Top = 615
Value = 1
Width = 255
End
Begin VB.TextBox txtLines
Height = 285
Left = 480
MaxLength = 2
TabIndex = 3
Top = 585
Width = 615
End
Begin VB.Label lblButton
AutoSize = -1 'True
Caption = "Wheel button action:"
Height = 195
Left = 120
TabIndex = 8
Top = 1320
Width = 1485
End
Begin VB.Image imgWheel
Height = 480
Left = 3360
Picture = "Main.frx":25D8
Top = 240
Width = 480
End
Begin VB.Label lblScrollPage
AutoSize = -1 'True
Caption = "one page at time"
Height = 195
Left = 480
TabIndex = 7
Top = 990
Width = 1185
End
Begin VB.Label lblScrollLines
AutoSize = -1 'True
Caption = "lines at time"
Height = 195
Left = 1200
TabIndex = 5
Top = 630
Width = 825
End
Begin VB.Label lblScroll
AutoSize = -1 'True
Caption = "Roll the wheel one notch to scroll:"
Height = 195
Left = 120
TabIndex = 1
Top = 240
Width = 2400
End
End
Begin VB.Label lblVersion
AutoSize = -1 'True
Caption = "Version"
ForeColor = &H80000011&
Height = 195
Left = 120
TabIndex = 20
Top = 5010
Width = 525
End
Begin VB.Menu mnuTray
Caption = "empty"
Visible = 0 'False
Begin VB.Menu mnuConfigure
Caption = "Configure"
End
Begin VB.Menu mnuVisit
Caption = "Visit my site"
End
Begin VB.Menu mnuExit
Caption = "Exit"
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private iniPath As String
Private WithEvents astMain As AdvSysTray
Attribute astMain.VB_VarHelpID = -1
Private pntTray As POINTAPI
Private rctTray As RECT, rctForm As RECT
Private Sub Form_Initialize()
InitCommonControls
End Sub
Private Sub Form_Load()
On Error GoTo ErrHand
Dim myCaption As String, buffer As String
Dim textStyle As Long, result As Long, pressKey As Long
Dim i As Integer
myCaption = App.Title & " by " & App.CompanyName
If App.PrevInstance Then
MsgBox App.Title & " is already running!", vbExclamation
End
End If
Me.Caption = myCaption
lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
iniPath = App.Path & "\" & App.EXEName & ".ini"
For i = 1 To 10
buffer = String$(100, vbNullChar)
result = GetPrivateProfileString("WheelButtonAction", "Caption" & CStr(i), "Action" & CStr(i), buffer, Len(buffer), iniPath)
pressKey = GetPrivateProfileInt("WheelButtonAction", "PressKey" & CStr(i), 0, iniPath)
If pressKey = 0 Then Exit For
cmbAction.AddItem Left$(buffer, result)
cmbAction.ItemData(i) = pressKey
Next
ReadSettings
textStyle = GetWindowLong(txtLines.hWnd, GWL_STYLE)
SetWindowLong txtLines.hWnd, GWL_STYLE, textStyle Or ES_NUMBER
sclLines.Value = txtLines.text
EnableScroll
ScrollLines IIf(optScrollLines.Value, CLng(txtLines.text), 0)
SetWheelButton cmbAction.ItemData(cmbAction.ListIndex), CLng(cmbAction.Tag)
For i = optCtrlKey.LBound To optCtrlKey.UBound
If optCtrlKey.Item(i).Value Then
SetCtrlKey i
Exit For
End If
Next
Set astMain = New AdvSysTray
astMain.Create Me
astMain.Tooltip = myCaption
If GetSetting(App.Title, "Settings", "FirstTime", True) Then
astMain.ShowBalloon "Program started successfully. Click here to configure it.", Me.Caption, NIIF_INFO
SaveSetting App.Title, "Settings", "FirstTime", False
End If
Exit Sub
ErrHand:
MsgBox Err.Description, vbCritical, Err.Source
End
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
AnimateHide
Cancel = True
Else
DisableScroll
astMain.Destroy
Set astMain = Nothing
End If
End Sub
Private Sub sclLines_Change()
txtLines.text = sclLines.Value
End Sub
Private Sub optScrollLines_Click()
txtLines.Enabled = optScrollLines.Value
sclLines.Enabled = txtLines.Enabled
End Sub
Private Sub optScrollPage_Click()
txtLines.Enabled = optScrollLines.Value
sclLines.Enabled = txtLines.Enabled
End Sub
Private Sub lblScrollLines_Click()
optScrollLines.Value = True
optScrollLines_Click
End Sub
Private Sub lblScrollPage_Click()
optScrollPage.Value = True
optScrollPage_Click
End Sub
Private Sub cmdOk_Click()
On Error GoTo ErrHand
Dim i As Integer
If CInt(txtLines.text) < 1 Then Exit Sub
SaveSetting App.Title, "Settings", "ScrollLines", txtLines.text
SaveSetting App.Title, "Settings", "ScrollPage", optScrollPage.Value
SaveSetting App.Title, "Settings", "WheelButton", cmbAction.ListIndex
ScrollLines IIf(optScrollLines.Value, CLng(txtLines.text), 0)
SetWheelButton cmbAction.ItemData(cmbAction.ListIndex), CLng(cmbAction.Tag)
For i = optCtrlKey.LBound To optCtrlKey.UBound
If optCtrlKey.Item(i).Value Then
SaveSetting App.Title, "Settings", "CtrlKey", i
SetCtrlKey i
Exit For
End If
Next
If optAllUsers.Value Then
DeleteShortcut "Startup"
CreateShortcut "AllUsersStartup"
ElseIf optCurrentUser.Value Then
DeleteShortcut "AllUsersStartup"
CreateShortcut "Startup"
Else
DeleteShortcut "Startup"
DeleteShortcut "AllUsersStartup"
End If
AnimateHide
Exit Sub
ErrHand:
MsgBox Err.Description, vbCritical, Err.Source
Err.Clear
End Sub
Private Sub cmdCancel_Click()
ReadSettings
AnimateHide
End Sub
Private Sub astMain_LButtonDown()
GetCursorPos pntTray
End Sub
Private Sub astMain_RButtonDown()
GetCursorPos pntTray
End Sub
Private Sub astMain_LButtonDblClk()
AnimateShow
End Sub
Private Sub astMain_RButtonUp()
SetForegroundWindow Me.hWnd
If Not Me.Visible Then
Me.PopupMenu mnuTray, , , , mnuConfigure
End If
End Sub
Private Sub astMain_BalloonUserClick()
GetCursorPos pntTray
AnimateShow
End Sub
Private Sub mnuConfigure_Click()
astMain_LButtonDblClk
End Sub
Private Sub mnuVisit_Click()
ShellExecute Me.hWnd, vbNullString, "http://www.gasanov.net", vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
Private Sub mnuExit_Click()
Unload Me
End Sub
Private Sub ReadSettings()
txtLines.text = GetSetting(App.Title, "Settings", "ScrollLines", 3)
optScrollPage.Value = GetSetting(App.Title, "Settings", "ScrollPage", False)
optScrollLines.Value = Not optScrollPage.Value
cmbAction.ListIndex = GetSetting(App.Title, "Settings", "WheelButton", 0)
cmbAction.Tag = GetPrivateProfileInt("WheelButtonAction", "HoldKey" & cmbAction.ListIndex, 0, iniPath)
optCtrlKey.Item(GetSetting(App.Title, "Settings", "CtrlKey", 1)).Value = True
optAllUsers.Value = (Dir$(ShortcutPath("AllUsersStartup")) <> "")
optCurrentUser.Value = (Dir$(ShortcutPath("Startup")) <> "")
optManual.Value = Not (optAllUsers.Value Or optCurrentUser.Value)
End Sub
Private Sub AnimateShow()
If Me.Visible Then
SetForegroundWindow Me.hWnd
Else
rctTray.Left = pntTray.x
rctTray.Top = pntTray.y
rctTray.Right = pntTray.x
rctTray.Bottom = pntTray.y
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
GetWindowRect Me.hWnd, rctForm
DrawAnimatedRects Me.hWnd, IDANI_OPEN Or IDANI_CAPTION, rctTray, rctForm
Me.Show
End If
End Sub
Private Sub AnimateHide()
GetWindowRect Me.hWnd, rctForm
DrawAnimatedRects Me.hWnd, IDANI_CLOSE Or IDANI_CAPTION, rctForm, rctTray
Me.Hide
End Sub