-
Notifications
You must be signed in to change notification settings - Fork 1
/
cfAlpha.cls
703 lines (555 loc) · 27.3 KB
/
cfAlpha.cls
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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "cfAlpha"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'---------------------------------------------------------------------------------------
' Module : cfAlpha
' Author : beededea
' Date : 05/12/2023
' Purpose :
'---------------------------------------------------------------------------------------
'@IgnoreModule IntegerDataType, ModuleWithoutFolder
Option Explicit 'simple Alpha-Form (...to be filled with (mostly Img-) Content via .Widgets.Add)
Public WithEvents gaugeForm As cWidgetForm
Attribute gaugeForm.VB_VarHelpID = -1
Public collPSDNonUIElements As cCollection, FX As Long, FY As Long, FZ As Single 'available on the outside, even after the Form was closed
Private PSDWidth As Long
Private PSDHeight As Long
Private mGlowing As Boolean
'---------------------------------------------------------------------------------------
' Procedure : Class_Initialize
' Author : olaf schmidt
' Date : 31/07/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub Class_Initialize()
On Error GoTo Class_Initialize_Error
mGlowing = False ' when the alpha for the overlays arrives this might be usable
Set collPSDNonUIElements = New_c.Collection(False)
On Error GoTo 0
Exit Sub
Class_Initialize_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Class_Initialize of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : InitFromPSD
' Author : olaf schmidt
' Date : 31/07/2023
' Purpose : loads up the Cairo imageList with keyed entries and a surface from each and every PSD layer
' adds path X,Y and alpha to the excluded collection
' creates widgets with corresponding keynames, locations and sizes as per PSD for each layer
' cwOverlay class puts it on the screen
'---------------------------------------------------------------------------------------
'
Public Sub InitFromPSD(ByRef PSD_FileNameOrByteArray As Variant)
Const AlphaWithTaskbarEntry As Integer = 6
Const AlphaNoTaskbarEntry As Integer = 7
Dim I As Long: I = 0
Dim W As cWidgetBase
On Error GoTo InitFromPSD_Error
'create the Alpha-capable Top-Level-Form
Set gaugeForm = Cairo.WidgetForms.Create(IIf(App.LogMode, AlphaNoTaskbarEntry, AlphaWithTaskbarEntry), widgetName, True, 1, 1)
gaugeForm.WidgetRoot.BackColor = -1
With New_c.SimplePSD(PSD_FileNameOrByteArray) 'create a new PSD-Parser.instance (and load the passed content)
PSDWidth = .Width
PSDHeight = .Height 'store the original Psd-Pixel-Width/Height in Private vars (as the base from which we calculate the zoomed Form-Width/Height)
For I = 0 To .LayersCount - 1 ' loop through each of the Layers in the PSD
If .LayerByteSize(I) Then ' this is a true Alpha-Surface-Layer and not just a PSD layer 'group'
If .LayerAlphaPercent(I) > 0 Then ' only handles layers that have an opacity greater than 0 - need to note this for the future, this will cause a problem!
'add each current Layer path and surface object into the global ImageList collection (using LayerPath as the ImageKey)
Cairo.ImageList.AddSurface .LayerPath(I), .LayerSurface(I)
If collPSDNonUIElements.Exists(.LayerPath(I)) Then ' we do not create Widgets for those in this exclude list.
'we add layer info. (used in cwOverlay) to the "excluded paths" previously defined in Sub Main,
collPSDNonUIElements(.LayerPath(I)) = Array(.LayerX(I), .LayerY(I), Val(PzGOpacity) / 100) 'here we update the so far empty slots with the PSD-offsets
Else 'everything not in the exclude-list will get its own Widget-instance
Set W = gaugeForm.Widgets.Add(New cwAlphaImg, LCase$(.LayerPath(I)), .LayerX(I), .LayerY(I), .LayerWidth(I), .LayerHeight(I)).Widget
'Set W = gaugeForm.Widgets.Add(New_W("cwAlphaImg"), LCase$(.LayerPath(I)), .LayerX(I), .LayerY(I), .LayerWidth(I), .LayerHeight(I)).Widget
W.ImageKey = W.Key 'W.Key equals ImageList-Key, set above - and LayerPath(i) at this point ... set it also as the ImageKey of our new created Widget
If PzGOpacity < 1 Then
W.Alpha = Val(PzGOpacity) / 100
Else
W.Alpha = 1
End If
W.Tag = 0.05
' set the default characteristics of the non-interactive areas
' note: the clickable layers characteristics are set in adjustMainControls
' all non-clickable Layer-Widgets will be -1 or "non-hoverable" and "fully click-through"
W.HoverColor = -1 ' task: might change this later when new ver or RC6 arrives
If PzGEnableTooltips = "1" Then W.ToolTip = "Ctrl + mouse scrollwheel up/down to resize, you can also drag me to a new position."
W.MousePointer = IDC_SIZEALL
End If
End If
End If
Next I
End With '<-- the Parser-instance will be destroyed here (freeing the Memory, the internal PSD-Layers have occupied)
Set overlayWidget = gaugeForm.Widgets.Add(New cwOverlay, "Overlay", 0, 0, PSDWidth, PSDHeight)
Set overlayWidget.cCollOverlayImages = collPSDNonUIElements 'make the excluded PSD-Surface-Paths known to the Overlay-Widget
overlayWidget.cxPerc = 0.4940476 'define the relative center (within cwOverlay, which has the same size as the Form and the PSD...) this is used for clock-hand-positioning
overlayWidget.cyPerc = 0.4727272
On Error GoTo 0
Exit Sub
InitFromPSD_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure InitFromPSD of Class Module cfAlpha"
End Sub
'
'---------------------------------------------------------------------------------------
' Procedure : gaugeForm_BubblingEvent
' Author : beededea
' Date : 31/07/2023
' Purpose : central handling of all Click-Events
'---------------------------------------------------------------------------------------
'
Private Sub gaugeForm_BubblingEvent(ByRef Sender As Object, ByRef EventName As String, ByRef P1 As Variant, ByRef P2 As Variant, ByRef P3 As Variant, ByRef P4 As Variant, ByRef P5 As Variant, ByRef P6 As Variant, ByRef P7 As Variant)
On Error GoTo gaugeForm_BubblingEvent_Error
If PzGIgnoreMouse = "1" Then Exit Sub
If EventName = "W_MouseMove" Then
Select Case LCase$(Sender.Widget.Key)
Case "housing/lockbutton"
If PzGEnableBalloonTooltips = "1" Then CreateToolTip gaugeForm.hwnd, "Click me to lock the widget in place. This lock can be released by clicking again on the lock button, or in the preferences. A locking sound will denote the button's operation.", _
TTIconInfo, widgetName & " Lock Button Help", , , , True
Case "housing/prefsbutton"
If PzGEnableBalloonTooltips = "1" Then CreateToolTip gaugeForm.hwnd, "Click me to open the preferences utility. The configuration of the widget is performed using the preference utility.", _
TTIconInfo, widgetName & " Prefs Button Help", , , , True
Case "housing/tickbutton"
If PzGEnableBalloonTooltips = "1" Then CreateToolTip gaugeForm.hwnd, "Click here to toggle the tick type from once per second to a more fluid, continuous movement.", _
TTIconInfo, widgetName & " Tick Button Help", , , , True
Case "housing/switchfacesbutton"
If PzGEnableBalloonTooltips = "1" Then CreateToolTip gaugeForm.hwnd, "This button is not allocated a function in this particular widget.", _
TTIconInfo, widgetName & " Switch Faces Button Help", , , , True
Case "housing/stopbutton"
If PzGEnableBalloonTooltips = "1" Then CreateToolTip gaugeForm.hwnd, "This button stops all animated clock functions for this widget, hand movements &c .", _
TTIconInfo, widgetName & " Stop Button Help", , , , True
Case "housing/startbutton"
If PzGEnableBalloonTooltips = "1" Then CreateToolTip gaugeForm.hwnd, "This button restarts all stopped clock functions for this widget, hand movement &c .", _
TTIconInfo, widgetName & " Start Button Help", , , , True
Case "housing/helpbutton"
If PzGEnableBalloonTooltips = "1" Then CreateToolTip gaugeForm.hwnd, "This button opens the one-page help file for this widget. There is a further detailed CHM help file available from the right-click menu that contains all the information that you need to run this widget.", _
TTIconInfo, widgetName & " Help Button Help", , , , True
Case Else
If PzGEnableBalloonTooltips = "1" Then CreateToolTip gaugeForm.hwnd, "Right Click to open the menu and the preferences. CTRL+ Mouse scrollwheel UP/DOWN to resize. " _
& vbCrLf & "You can turn off the balloon tooltips in the preferences.", _
TTIconInfo, widgetName & " Configuration Help", , , , True
End Select
End If
If EventName = "W_MouseDown" Then
Select Case LCase$(Sender.Widget.Key)
Case "housing/lockbutton"
Call lockbutton_mouseDown(Sender)
Case "housing/prefsbutton"
Call prefsbutton_mouseDown(Sender)
Case "housing/tickbutton"
Call tickbutton_mouseDown(Sender)
Case "housing/switchfacesbutton"
Call switchfacesbutton_mouseDown(Sender)
Case "housing/stopbutton"
Call stopbutton_mouseDown(Sender)
Case Else
Debug.Print Sender.Widget.Key
End Select
End If
If EventName = "W_MouseUp" Then
Select Case LCase$(Sender.Widget.Key)
Case "housing/prefsbutton"
Sender.Widget.Alpha = Val(PzGOpacity) / 100
Sender.Widget.Refresh
Case "housing/switchfacesbutton"
Call switchfacesbutton_mouseUp(Sender)
Case "housing/stopbutton"
Call stopbutton_mouseUp(Sender)
Case Else
Debug.Print Sender.Widget.Key
End Select
End If
If EventName = "W_Click" Then
Select Case LCase$(Sender.Widget.Key)
Case "housing/helpbutton"
Call helpbutton_click
Case "housing/startbutton"
Call startbutton_click
Case Else
Debug.Print Sender.Widget.Key
End Select
End If
On Error GoTo 0
Exit Sub
gaugeForm_BubblingEvent_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure gaugeForm_BubblingEvent of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : helpbutton_click
' Author : beededea
' Date : 03/08/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub helpbutton_click()
On Error GoTo helpbutton_click_Error
Call helpSplash
On Error GoTo 0
Exit Sub
helpbutton_click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure helpbutton_click of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : startbutton_click
' Author : beededea
' Date : 03/08/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub startbutton_click()
On Error GoTo startbutton_click_Error
Dim fileToPlay As String: fileToPlay = vbNullString
Call TurnFunctionsOn
fileToPlay = "ting.wav"
If PzGEnableSounds = "1" And fFExists(App.path & "\resources\sounds\" & fileToPlay) Then
PlaySound App.path & "\resources\sounds\" & fileToPlay, ByVal 0&, SND_FILENAME Or SND_ASYNC
End If
On Error GoTo 0
Exit Sub
startbutton_click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure startbutton_click of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : stopbutton_mouseUp
' Author : beededea
' Date : 03/08/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub stopbutton_mouseUp(ByRef Sender As Object)
Dim fileToPlay As String: fileToPlay = vbNullString
On Error GoTo stopbutton_mouseUp_Error
Sender.Widget.Alpha = Val(PzGOpacity) / 100
Sender.Widget.Refresh
Call SwitchOff
fileToPlay = "stop.wav"
If PzGEnableSounds = "1" And fFExists(App.path & "\resources\sounds\" & fileToPlay) Then
PlaySound App.path & "\resources\sounds\" & fileToPlay, ByVal 0&, SND_FILENAME Or SND_ASYNC
End If
On Error GoTo 0
Exit Sub
stopbutton_mouseUp_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure stopbutton_mouseUp of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : stopbutton_mouseDown
' Author : beededea
' Date : 03/08/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub stopbutton_mouseDown(ByRef Sender As Object)
On Error GoTo stopbutton_mouseDown_Error
Sender.Widget.Alpha = 0
Sender.Widget.Refresh
On Error GoTo 0
Exit Sub
stopbutton_mouseDown_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure stopbutton_mouseDown of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : switchfacesbutton_mouseDown
' Author : beededea
' Date : 03/08/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub switchfacesbutton_mouseDown(ByRef Sender As Object)
On Error GoTo switchfacesbutton_mouseDown_Error
Sender.Widget.Alpha = 0
Sender.Widget.Refresh
On Error GoTo 0
Exit Sub
switchfacesbutton_mouseDown_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure switchfacesbutton_mouseDown of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : switchfacesbutton_mouseUp
' Author : beededea
' Date : 03/08/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub switchfacesbutton_mouseUp(ByRef Sender As Object)
Dim fileToPlay As String: fileToPlay = vbNullString
On Error GoTo switchfacesbutton_mouseUp_Error
Sender.Widget.Alpha = Val(PzGOpacity) / 100
Sender.Widget.Refresh
fileToPlay = "till.wav"
If PzGEnableSounds = "1" And fFExists(App.path & "\resources\sounds\" & fileToPlay) Then
PlaySound App.path & "\resources\sounds\" & fileToPlay, ByVal 0&, SND_FILENAME Or SND_ASYNC
End If
On Error GoTo 0
Exit Sub
switchfacesbutton_mouseUp_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure switchfacesbutton_mouseUp of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : lockbutton_mouseDown
' Author : beededea
' Date : 03/08/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub lockbutton_mouseDown(ByRef Sender As Object)
On Error GoTo lockbutton_mouseDown_Error
If overlayWidget.Locked = False Then
Sender.Widget.Alpha = 0
Else
Sender.Widget.Alpha = Val(PzGOpacity) / 100
End If
Sender.Widget.Refresh ' this removes the delay in the lockButton depressing
Call lockWidget
On Error GoTo 0
Exit Sub
lockbutton_mouseDown_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure lockbutton_mouseDown of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : prefsbutton_mouseDown
' Author : beededea
' Date : 03/08/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub prefsbutton_mouseDown(ByRef Sender As Object)
Dim fileToPlay As String: fileToPlay = vbNullString
On Error GoTo prefsbutton_mouseDown_Error
Sender.Widget.Alpha = 0
'Sender.Widget.Visible = False
Sender.Widget.Refresh ' this removes the delay in the Button depressing
fileToPlay = "winding.wav"
If PzGEnableSounds = "1" And fFExists(App.path & "\resources\sounds\" & fileToPlay) Then
PlaySound App.path & "\resources\sounds\" & fileToPlay, ByVal 0&, SND_FILENAME Or SND_ASYNC
End If
'MsgBox "prefsbutton_mouseDown"
Call makeProgramPreferencesAvailable
On Error GoTo 0
Exit Sub
prefsbutton_mouseDown_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure prefsbutton_mouseDown of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : tickbutton_mouseDown
' Author : beededea
' Date : 03/08/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub tickbutton_mouseDown(ByRef Sender As Object)
Dim fileToPlay As String: fileToPlay = vbNullString
On Error GoTo tickbutton_mouseDown_Error
If overlayWidget.SmoothSecondHand = True Then
overlayWidget.SmoothSecondHand = False
Sender.Widget.Alpha = Val(PzGOpacity) / 100
PzGSmoothSecondHand = "0"
Else
overlayWidget.SmoothSecondHand = True
Sender.Widget.Alpha = 0 ' sender is the referring control
PzGSmoothSecondHand = "1"
End If
Sender.Widget.Refresh ' this removes the delay in the Button depressing
fileToPlay = "lock.wav"
If PzGEnableSounds = "1" And fFExists(App.path & "\resources\sounds\" & fileToPlay) Then
PlaySound App.path & "\resources\sounds\" & fileToPlay, ByVal 0&, SND_FILENAME Or SND_ASYNC
End If
sPutINISetting "Software\PzJustClock", "smoothSecondHand", PzGSmoothSecondHand, PzGSettingsFile
On Error GoTo 0
Exit Sub
tickbutton_mouseDown_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure tickbutton_mouseDown of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : gaugeForm_DblClick
' Author : beededea
' Date : 05/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub gaugeForm_DblClick()
Dim userprof As String: userprof = vbNullString
Dim thisCommand As String: thisCommand = vbNullString
On Error GoTo gaugeForm_DblClick_Error
' If PzGIgnoreMouse = "1" Then Exit Sub
If LTrim$(PzGDblClickCommand) = vbNullString Then Exit Sub
thisCommand = PzGDblClickCommand
If InStr(thisCommand, "%userprofile%") Then
userprof = Environ$("USERPROFILE")
thisCommand = Replace(thisCommand, "%userprofile%", userprof)
End If
' .91 DAEB 08/12/2022 frmMain.frm SteamyDock responds to %systemroot% environment variables during runCommand
If InStr(thisCommand, "%systemroot%") Then
userprof = Environ$("SYSTEMROOT")
thisCommand = Replace(thisCommand, "%systemroot%", userprof)
End If
If SHIFT_1 = True Then
SHIFT_1 = False
Call ShellExecute(fAlpha.gaugeForm.hwnd, "Open", PzGOpenFile, vbNullString, App.path, 1)
Else
Call ShellExecute(fAlpha.gaugeForm.hwnd, "runas", thisCommand, vbNullString, App.path, 1)
End If
On Error GoTo 0
Exit Sub
gaugeForm_DblClick_Error:
With Err
If .Number <> 0 Then
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure gaugeForm_DblClick of Class Module cfMain"
Resume Next
End If
End With
End Sub
'---------------------------------------------------------------------------------------
' Procedure : gaugeForm_KeyDown
' Author : beededea
' Date : 01/06/2019
' Purpose : get F5 and SHIFT keypresses
'---------------------------------------------------------------------------------------
'
Private Sub gaugeForm_KeyDown(ByRef KeyCode As Integer, ByRef Shift As Integer)
On Error GoTo gaugeForm_KeyDown_Error
Call getKeyPress(KeyCode, Shift) ' will not catch Shift or CTRL keypresses on their own, must be combination with another key.
On Error GoTo 0
Exit Sub
gaugeForm_KeyDown_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure gaugeForm_KeyDown of Class Module cfMain"
End Sub
''
'---------------------------------------------------------------------------------------
' Procedure : gaugeForm_MouseUp
' Author : beededea
' Date : 05/05/2023
' Purpose : save the form x,y position when ever the globe/form is dragged
'---------------------------------------------------------------------------------------
'
Private Sub gaugeForm_MouseUp(ByRef Button As Integer, ByRef Shift As Integer, ByRef x As Single, ByRef y As Single)
On Error GoTo gaugeForm_MouseUp_Error
Call savePosition
On Error GoTo 0
Exit Sub
gaugeForm_MouseUp_Error:
With Err
If .Number <> 0 Then
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure gaugeForm_MouseUp of Class Module cfMain"
Resume Next
End If
End With
End Sub
'---------------------------------------------------------------------------------------
' Procedure : gaugeForm_MouseMove
' Author : beededea
' Date : 31/07/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub gaugeForm_MouseMove(ByRef Button As Integer, ByRef Shift As Integer, ByRef x As Single, ByRef y As Single)
Static x0 As Single, y0 As Single: If Button = 0 Then x0 = x: y0 = y 'just store the offsets when no button is down
On Error GoTo gaugeForm_MouseMove_Error
If overlayWidget.Locked = True Then Exit Sub
If PzGIgnoreMouse = "1" Then Exit Sub
If Button = vbLeftButton And Not gaugeForm.ActiveWidget Is Nothing Then 'Form-Dragging (under certain conditions)
FX = (x - x0) * gaugeForm.WidgetRoot.Zoom + gaugeForm.Left
FY = (y - y0) * gaugeForm.WidgetRoot.Zoom + gaugeForm.Top
gaugeForm.Move FX, FY
End If
On Error GoTo 0
Exit Sub
gaugeForm_MouseMove_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure gaugeForm_MouseMove of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : gaugeForm_MouseWheel
' Author : beededea
' Date : 31/07/2023
' Purpose : rotate forward positive = smaller
'---------------------------------------------------------------------------------------
'
Private Sub gaugeForm_MouseWheel(ByVal MouseKeys As Long, ByVal Rotation As Long, ByVal Xpos As Single, ByVal Ypos As Single)
Dim RotationDirection As Long: RotationDirection = 0
On Error GoTo gaugeForm_MouseWheel_Error
If PzGScrollWheelDirection = "1" Then
If Rotation > 0 Then
RotationDirection = 0 - Abs(Rotation)
Else
RotationDirection = Abs(Rotation)
End If
Else
RotationDirection = Rotation
End If
If MouseKeys = 8 Then Call AdjustZoom(FZ + RotationDirection / 2400) 'change the Zoom only, when the Ctrl-Key is down
On Error GoTo 0
Exit Sub
gaugeForm_MouseWheel_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure gaugeForm_MouseWheel of Class Module cfAlpha"
End Sub
''
''---------------------------------------------------------------------------------------
'' Procedure : gaugeForm_ResizeWithDimensionsDIP
'' Author : beededea
'' Date : 31/07/2023
'' Purpose : put any other resizing action in here - unused
''---------------------------------------------------------------------------------------
''
'Private Sub gaugeForm_ResizeWithDimensionsDIP(ByVal dx As Single, ByVal dy As Single)
' On Error GoTo gaugeForm_ResizeWithDimensionsDIP_Error
'
' 'If Not CloseWidget Is Nothing Then CloseWidget.Move dx - 32, 0, 32, 32 'place the close-widget at the top-right of the form
'
' On Error GoTo 0
' Exit Sub
'
'gaugeForm_ResizeWithDimensionsDIP_Error:
'
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure gaugeForm_ResizeWithDimensionsDIP of Class Module cfAlpha"
'End Sub
'---------------------------------------------------------------------------------------
' Procedure : AdjustZoom
' Author : olaf schmidt
' Date : 31/07/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Public Sub AdjustZoom(ByVal NewZoom As Single)
On Error GoTo AdjustZoom_Error
FZ = NewZoom
If FZ < 0.05 Then FZ = 0.05 Else If FZ > 3 Then FZ = 3 'keep FZ within a sane ZoomInterval
gaugeForm.WidgetRoot.Zoom = FZ '* gaugeForm.WidgetRoot.CurrentMonitor.Zoom '<-- if the multiplicator is activated, we'd have DPI-awareness on high-res monitors
gaugeForm.Move gaugeForm.Left, gaugeForm.Top, PSDWidth * gaugeForm.WidgetRoot.Zoom, PSDHeight * gaugeForm.WidgetRoot.Zoom
' when resized from the gauge scroll up/down it needs to write it back so the size is correct when prefs opened.
PzGGaugeSize = LTrim$(Str$(NewZoom * 100))
If panzerPrefs.IsVisible = True Then panzerPrefs.sliGaugeSize = Val(PzGGaugeSize)
On Error GoTo 0
Exit Sub
AdjustZoom_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure AdjustZoom of Class Module cfAlpha"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : W_MouseDown
' Author :
' Date : 09/05/2023
' Purpose :
'---------------------------------------------------------------------------------------
'
Private Sub gaugeForm_MouseDown(ByRef Button As Integer, ByRef Shift As Integer, ByRef x As Single, ByRef y As Single)
On Error GoTo W_MouseDown_Error
If Button = vbRightButton Then
Call menuForm.PopupMenu(menuForm.mnuMainMenu)
Else
If PzGIgnoreMouse = "1" Then Exit Sub
' do whatever you want with a mouseDown here, not doing anything at the moment but we will...
End If
On Error GoTo 0
Exit Sub
W_MouseDown_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure W_MouseDown of Class Module cwOverlay"
End Sub