-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathTaskBar.frm
More file actions
1162 lines (748 loc) · 31.2 KB
/
TaskBar.frm
File metadata and controls
1162 lines (748 loc) · 31.2 KB
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
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Begin VB.Form TaskBar
AutoRedraw = -1 'True
BackColor = &H00000000&
BorderStyle = 0 'None
ClientHeight = 210
ClientLeft = 0
ClientTop = 0
ClientWidth = 210
ControlBox = 0 'False
LinkTopic = "Form1"
ScaleHeight = 14
ScaleMode = 3 'Pixel
ScaleWidth = 14
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.Timer timUpdateClock
Interval = 1000
Left = 120
Top = 120
End
Begin VB.Timer timEnumerateTasks
Interval = 400
Left = 4560
Top = 1200
End
End
Attribute VB_Name = "TaskBar"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'--------------------------------------------------------------------------------
' Component : TaskBar
' Project : ViDock
'
' Description: The physical dock object
'
'--------------------------------------------------------------------------------
Option Explicit
Implements IHookSink
Private Const EFFECT_MARGIN As Single = 3
Private Const ACTUAL_ICON_SIZE As Long = 16
Private Const SEPERATOR_SIZE As Long = 5
Private Const DOCK_MARGIN_X As Long = 100
Private m_dockPopup As DockPopup
Private WithEvents m_listMenu As ListMenu
Attribute m_listMenu.VB_VarHelpID = -1
Private WithEvents m_listMenuPointer As ListMenuPointer
Attribute m_listMenuPointer.VB_VarHelpID = -1
Private m_TaskbarBackgroundGraphics As GDIPGraphics
Private m_TaskbandGraphics As GDIPGraphics
Private m_TaskbandBitmap As GDIPBitmap
Private m_backgroundImage As GDIPImage
Private m_separator As GDIPImage
Private m_indicatorImage As GDIPImage
Private m_indicatorSlices As Collection
Private WithEvents m_menuBar As NewMenuBar
Attribute m_menuBar.VB_VarHelpID = -1
Private m_systemTrayPopup As TrayPopup
Private WithEvents m_clock As SystemClock
Attribute m_clock.VB_VarHelpID = -1
Private m_arrowImage As GDIPImage
Private m_arrowSlices As Collection
Private m_arrowPlacement As gdiplus.RECTL
Private m_arrowState As ButtonState
Private m_taskList As TaskList
Private m_currentItemCount As Long
Private m_processIndex As Long
Private m_layeredWindowProperties As LayerdWindowHandles
Private m_taskbandDimensions As gdiplus.RECTL
Private m_visibleList As Collection
Private m_sizeFactor As Double
Private m_lastSelectedProcess As Process
Private m_lastProcessShowcased As Process
Private m_objectBeingMouseTracked As Object
Private m_initialized As Boolean
Private m_Shell_Hook_Msg_ID As Long
Private m_processArea As Object
Private m_groupMenu As clsMenu
Private WithEvents m_startButton As StartOrb
Attribute m_startButton.VB_VarHelpID = -1
Private m_slices As Collection
Private m_menuBarSlice As Slice
Private m_mouseTracking As Boolean
Private m_ignoreTrayMenuSpawn As Boolean
Private m_componentOrder As Collection
Private m_mousePosition As POINTS
Sub ApplyGlass()
Dim a As Margins '??????????????
Dim bb As DWM_BLURBEHIND
Dim hr As Long
'make entire region glass (for invisible effect)
a.m_Left = -1
a.m_Top = -1
a.m_Right = -1
a.m_Bottom = -1
DwmIsCompositionEnabled 1
Me.BackColor = vbBlack
'If DwmExtendFrameIntoClientArea(Me.hWnd, a) <> S_OK Then
'MsgBox "Error!"
'End If
End Sub
Private Sub Form_Activate()
If m_systemTrayPopup.Visible Then
m_systemTrayPopup.Hide
End If
End Sub
Sub AddPinnedApplicationsFirst()
On Error GoTo Handler
Dim thisProcess As Process
For Each thisProcess In Settings.PinnedApplications
m_taskList.Processes.Add thisProcess, thisProcess.GetKey
Next
Handler:
End Sub
Private Sub Form_DragDropStack(szStackSpec As String)
'On Error GoTo Handler
Dim stackCaption As String
stackCaption = StrEnd(szStackSpec, "\")
If IsPathAFolder(szStackSpec) Then
Dim newProcess As New Process
newProcess.Constructor 0, Environ("windir") & "\explorer.exe"
newProcess.CreateIconFromPath
newProcess.Path = szStackSpec
newProcess.Caption = stackCaption
newProcess.IsStack = True
If Not Exists(m_taskList.Processes, newProcess.GetKey) Then
newProcess.Pinned = True
AddToCollectionAtPosition m_taskList.Processes, newProcess, 1, newProcess.GetKey
AddToCollectionAtPosition Settings.PinnedApplications, newProcess, 1
End If
End If
Exit Sub
Handler:
MsgBox Err.Description
End Sub
Sub Form_DragDropFile(sFile As String)
On Error GoTo Handler
If Not AddPinnedApp(sFile) Then Exit Sub
Dim szFileName As String
szFileName = StrEnd(sFile, "\")
FileCopy sFile, Environ("appdata") & "\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\" & szFileName
Exit Sub
Handler:
LogError 0, "DragDropFile", "TaskBar", Err.Description
End Sub
Function AddPinnedApp(sFile As String) As Boolean
On Error GoTo Handler
Dim thisLink As ShellLink
Dim backupCaption As String
Dim extension As String
thisLink = GetShortcut(CStr(sFile))
If InStr(sFile, ".") > 0 And InStr(sFile, "\") Then
backupCaption = StrEnd(sFile, "\")
extension = StrEnd(backupCaption, ".")
backupCaption = Mid(backupCaption, 1, Len(backupCaption) - Len(extension) - 1)
End If
If FileExists(thisLink.szPath) Then
Dim newProcess As New Process
newProcess.Constructor 0, thisLink.szPath
newProcess.CreateIconFromPath
newProcess.Arguments = thisLink.szArguments
newProcess.PhysicalLinkFile = sFile
If newProcess.Caption = vbNullString Then
newProcess.Caption = backupCaption
End If
If Not Exists(m_taskList.Processes, newProcess.GetKey) Then
newProcess.Pinned = True
AddToCollectionAtPosition m_taskList.Processes, newProcess, 1, newProcess.GetKey
AddToCollectionAtPosition Settings.PinnedApplications, newProcess, 1
End If
End If
AddPinnedApp = True
Exit Function
Handler:
MsgBox Err.Description
End Function
Sub Initialize()
If Me.Left <> 0 Or Me.Top <> 0 Or Me.Width <> Screen.Width Or Me.Height <> (36 * Screen.TwipsPerPixelY) Then
Me.Move 0, 0, Screen.Width, 36 * Screen.TwipsPerPixelY
End If
Set m_startButton = New StartOrb
Set m_taskList = New TaskList
Set m_dockPopup = New DockPopup
Set m_listMenu = New ListMenu
Set m_listMenuPointer = New ListMenuPointer
Set m_systemTrayPopup = New TrayPopup
Set m_clock = New SystemClock
Set m_processArea = Me
Set m_componentOrder = New Collection
Set m_arrowSlices = MenuListHelper.CreateButtonFromXML("tray_arrow", m_arrowImage)
Set m_indicatorSlices = MenuListHelper.CreateButtonFromXML("indicator", m_indicatorImage)
If m_indicatorSlices.Count > 0 Then
'Set m_indicatorFirstSlice = m_indicatorSlices(1)
End If
m_arrowPlacement = CreateRectL(16, 16, Me.ScaleWidth - 19, 5)
m_arrowState = ButtonUnpressed
Set m_menuBar = New NewMenuBar
Set m_backgroundImage = New GDIPImage
Set m_separator = New GDIPImage
'Set m_indicator = New GDIPImage
'Set m_textPath = New GDIPGraphicPath
Set m_visibleList = New Collection
m_separator.FromFile App.Path & "\resources\separator.png"
'm_indicator.FromFile App.Path & "\resources\indicator.png"
Set m_slices = SliceHelper.CreateSlicesFromXML("background", m_backgroundImage)
If ExistInCol(m_slices, "bar") Then
Set m_menuBarSlice = m_slices("bar")
End If
Set m_layeredWindowProperties = MakeLayerdWindow(Me)
' ShowWindow TaskbarHandler, SW_HIDE
'Set m_systemTray = New SystemTrayManager
'Set m_systemTray.HostForm = Me
'm_systemTray.Popup = m_dockPopup
'm_systemTray.Dimensions = CreateRectL(0, 0, 0, 3)
Set m_menuBar.HostForm = Me
m_menuBar.Dimensions = CreateRectL(Me.ScaleHeight, Me.ScaleWidth - 300, 50, 0)
'm_menuBar.Dimensions = CreateRectF(50, 0, Me.ScaleHeight, Me.ScaleWidth - 300)
m_menuBar.Background = m_backgroundImage
'Set owner of the window to me
SetOwner Me.hWnd, m_startButton.hWnd
m_startButton.Show
If Not m_menuBarSlice Is Nothing Then
m_startButton.Move 0, (m_menuBarSlice.Height / 2 - m_startButton.ScaleHeight / 2) * Screen.TwipsPerPixelY
End If
AppHelper.LoadWindowsPinnedApps Me
AddPinnedApplicationsFirst
m_initialized = True
End Sub
Private Sub ResizeTaskBandIfNeeded(newItemNumber As Long)
If m_currentItemCount = newItemNumber Then
Exit Sub
End If
Set m_TaskbandGraphics = New GDIPGraphics
Set m_TaskbandBitmap = New GDIPBitmap
m_TaskbandBitmap.CreateFromSizeFormat newItemNumber * (ACTUAL_ICON_SIZE + SEPERATOR_SIZE), (ACTUAL_ICON_SIZE + SEPERATOR_SIZE), GDIPlusWrapper.Format32bppArgb
m_TaskbandGraphics.FromImage m_TaskbandBitmap.Image
m_currentItemCount = newItemNumber
CalculateTaskbandDimensions
ResetProcessPositions
End Sub
Private Sub Form_Initialize()
If GetWindowsOSVersion.dwMajorVersion > 5 Then
ChangeWindowMessageFilter WM_DROPFILES, MSGFLT_ADD
ChangeWindowMessageFilter WM_COPYDATA, MSGFLT_ADD
ChangeWindowMessageFilter &H49, MSGFLT_ADD
End If
DragAcceptFiles Me.hWnd, APITRUE
End Sub
Private Sub Form_Load()
Initialize
'ApplyDWMEffect
CalculateTaskbandDimensions
HookWindow Me.hWnd, Me
RegisterShellHookWindow Me.hWnd
m_Shell_Hook_Msg_ID = WinAPIHelper.RegisterWindowMessage("SHELLHOOK")
TrackMouseEvents Me.hWnd
'StayOnTop Me, True
End Sub
Private Function ReleaseGraphics()
m_TaskbarBackgroundGraphics.ReleaseHDC m_layeredWindowProperties.theDC
'm_TaskbandGraphics.ReleaseHDC
End Function
Private Function InitializeGraphics()
Set m_TaskbarBackgroundGraphics = New GDIPGraphics
'm_graphics.FromHDC Me.hdc
m_TaskbarBackgroundGraphics.FromHDC m_layeredWindowProperties.theDC
'm_TaskbarBackgroundGraphics.SmoothingMode = SmoothingModeHighQuality
'm_TaskbarBackgroundGraphics.InterpolationMode = InterpolationModeHighQualityBicubic
m_TaskbarBackgroundGraphics.TextRenderingHint = TextRenderingHintClearTypeGridFit
m_TaskbarBackgroundGraphics.SmoothingMode = SmoothingModeHighQuality
m_TaskbarBackgroundGraphics.PixelOffsetMode = PixelOffsetModeHighQuality
'm_TaskbarBackgroundGraphics.CompositingMode = CompositingModeSourceCopy
'm_TaskbarBackgroundGraphics.CompositingMode = CompositingModeSourceOver
'm_TaskbarBackgroundGraphics.CompositingQuality = CompositingQualityHighQuality
m_TaskbarBackgroundGraphics.InterpolationMode = InterpolationModeNearestNeighbor
m_clock.Initialize m_TaskbarBackgroundGraphics
End Function
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MousePosition As POINTS
MousePosition.X = X
MousePosition.Y = Y
If MouseInsideObject(MousePosition, m_menuBar.Dimensions.Left, m_menuBar.Dimensions.Top, m_menuBar.Dimensions.Width, m_menuBar.Dimensions.Height) Then
m_menuBar.MouseDown Button, CSng(MousePosition.X), CSng(MousePosition.Y)
End If
If m_ignoreTrayMenuSpawn Then
If Not MouseInsideObject(MousePosition, m_arrowPlacement.Left, m_arrowPlacement.Top, m_arrowPlacement.Width, m_arrowPlacement.Height) Then
m_ignoreTrayMenuSpawn = False
End If
End If
End Sub
Private Sub ResetObjectBeingTracked()
If m_objectBeingMouseTracked Is Nothing Then Exit Sub
If m_objectBeingMouseTracked Is m_clock Then
m_clock.MouseLeft
ElseIf m_objectBeingMouseTracked Is m_menuBar Then
m_menuBar.MouseLeft
End If
Set m_objectBeingMouseTracked = Nothing
End Sub
Private Sub SetObjectBeingTracked(ByRef newObject As Object)
If Not m_objectBeingMouseTracked Is Nothing Then
If newObject Is m_objectBeingMouseTracked Then
Exit Sub
End If
If m_objectBeingMouseTracked Is m_clock Then
m_clock.MouseLeft
ElseIf m_objectBeingMouseTracked Is m_menuBar Then
m_menuBar.MouseLeft
ElseIf m_objectBeingMouseTracked Is m_processArea Then
Debug.Print "HandleMouseLeavingProcessArea"
HandleMouseLeavingProcessArea
End If
End If
Debug.Print "Changing tracking to: " & TypeName(newObject)
Set m_objectBeingMouseTracked = newObject
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If m_mouseTracking = False Then
m_mouseTracking = TrackMouseEvents(Me.hWnd)
'HandleMouseEnter
End If
m_mousePosition.X = X
m_mousePosition.Y = Y
If MouseInsideObject(m_mousePosition, m_clock.X, 0, m_clock.Width, Me.ScaleHeight) Then
SetObjectBeingTracked m_clock
m_clock.MouseMove Button, X, Y
ElseIf MouseInsideObject(m_mousePosition, m_arrowPlacement.Left, m_arrowPlacement.Top, m_arrowPlacement.Width, m_arrowPlacement.Height) Then
'ResetObjectBeingTracked
SetObjectBeingTracked timUpdateClock
If m_arrowState <> ButtonPressed Then
m_arrowState = ButtonPressed
DrawTaskList
End If
ElseIf Not GetSelectedProcess(X) Is Nothing Then
SetObjectBeingTracked m_processArea
HandleProcessSelection X
ElseIf MouseInsideObject(m_mousePosition, m_menuBar.Dimensions.Left, m_menuBar.Dimensions.Top, m_menuBar.Dimensions.Width, m_menuBar.Dimensions.Height) Then
SetObjectBeingTracked m_menuBar
m_menuBar.MouseMove m_mousePosition
Else
If Not m_systemTrayPopup.Visible Then
If m_arrowState <> ButtonUnpressed Then
m_arrowState = ButtonUnpressed
DrawTaskList
End If
End If
End If
End Sub
Private Sub HandleMouseLeavingProcessArea()
Set m_lastSelectedProcess = Nothing
m_dockPopup.Hide
End Sub
Private Sub HandleProcessSelection(ByVal X As Single)
Dim windowListMenuOpen As Boolean
Dim selectedProcess As Process
If Not m_listMenuPointer Is Nothing Then
If m_listMenuPointer.Visible Then
windowListMenuOpen = True
End If
End If
Set selectedProcess = GetSelectedProcess(X)
If m_lastSelectedProcess Is selectedProcess Then
Exit Sub
End If
Set m_lastSelectedProcess = selectedProcess
If selectedProcess Is Nothing Then
Set m_lastProcessShowcased = Nothing
Exit Sub
End If
If Not m_lastProcessShowcased Is Nothing Then
If m_lastProcessShowcased Is selectedProcess Then
Exit Sub
End If
End If
If Not windowListMenuOpen And Not m_systemTrayPopup.Visible Then
m_dockPopup.Top = Me.Top + Me.Height
m_dockPopup.ShowTextPopup GetBestProcessCaption(selectedProcess), m_taskbandDimensions.Left + (Me.Left / Screen.TwipsPerPixelX) + (selectedProcess.X) + (ACTUAL_ICON_SIZE / 2)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Dim isInsideTaskband As Boolean
Dim MousePosition As POINTS
MousePosition.X = X
MousePosition.Y = Y
If MouseInsideObject(MousePosition, m_arrowPlacement.Left, m_arrowPlacement.Top, m_arrowPlacement.Width, m_arrowPlacement.Height) Then
If m_ignoreTrayMenuSpawn Then
m_ignoreTrayMenuSpawn = False
Exit Sub
End If
m_systemTrayPopup.Top = Me.Top + Me.Height
m_systemTrayPopup.ShowTrayPopup m_arrowPlacement.Left
Exit Sub
End If
If HandleTaskbarMouseUp(Button) Then Exit Sub
If Button = vbRightButton Then
SystemMenuHandler SystemMenu.ShowMenu(Me.hWnd)
Exit Sub
End If
End Sub
Private Function HandleTaskbarMouseUp(Button As Integer) As Boolean
Dim singleWindow As Window
If Button = vbLeftButton Then
If m_lastSelectedProcess Is Nothing Then Exit Function
HandleTaskbarMouseUp = True
If m_lastSelectedProcess.IsStack Then
m_dockPopup.Hide
If (Not m_lastProcessShowcased Is Nothing) Or m_lastProcessShowcased Is m_lastSelectedProcess Then
m_listMenuPointer.Hide
Set m_lastProcessShowcased = Nothing
Set m_lastSelectedProcess = Nothing
Else
Set m_lastProcessShowcased = m_lastSelectedProcess
m_listMenuPointer.ShowList GetStackContents(m_lastSelectedProcess.Path), Me.Top, m_taskbandDimensions.Left + (Me.Left / Screen.TwipsPerPixelX) + (m_lastSelectedProcess.X * m_sizeFactor) + ((ACTUAL_ICON_SIZE * m_sizeFactor) / 2)
End If
ElseIf Not m_lastSelectedProcess.Running Then
ShellExec m_lastSelectedProcess.Path, m_lastSelectedProcess.Arguments
Else
If m_lastSelectedProcess.WindowCount = 1 Then
Set singleWindow = m_lastSelectedProcess.Window(1)
HandleWindow singleWindow.hWnd
Else
m_dockPopup.Hide
If m_lastProcessShowcased Is m_lastSelectedProcess Then
Set m_lastProcessShowcased = Nothing
m_listMenuPointer.Hide
Else
Set m_lastProcessShowcased = m_lastSelectedProcess
m_listMenuPointer.ShowList m_lastSelectedProcess.Window, Me.Top + Me.Height, m_taskbandDimensions.Left + (Me.Left / Screen.TwipsPerPixelX) + (m_lastSelectedProcess.X) + (ACTUAL_ICON_SIZE / 2), vbPopupMenuLeftAlign
End If
End If
End If
ElseIf Button = vbRightButton Then
'Set m_currentJumpLists = m_lastSelectedProcess.GetJumpLists
If Not m_lastSelectedProcess Is Nothing Then
Set m_groupMenu = BuildMenuWithoutJumpList()
m_groupMenu.EditItem 5, IIf(m_lastSelectedProcess.Pinned, "Unpin", "Pin")
HandleProcessMenuResult m_groupMenu.ShowMenu(Me.hWnd), m_lastSelectedProcess
HandleTaskbarMouseUp = True
End If
End If
End Function
Private Sub Form_OLEDragDrop(data As DataObject, _
Effect As Long, _
Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)
Dim j As Long
If data.GetFormat(vbCFFiles) = True Then
For j = 1 To data.Files.Count
If (GetAttr(data.Files.Item(j)) And vbDirectory) Then
Form_DragDropStack data.Files.Item(j)
Else
Form_DragDropFile data.Files.Item(j)
End If
Next
End If
End Sub
Private Sub Form_OLEDragOver(data As DataObject, _
Effect As Long, _
Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single, _
state As Integer)
Dim theFileExtension As String
Debug.Print data.Files.Item(1)
Effect = vbDropEffectNone
If Not data.GetFormat(vbCFFiles) = True Then
Exit Sub
End If
If Not (GetAttr(data.Files.Item(1)) = vbDirectory) Then
theFileExtension = UCase(StrEnd(data.Files.Item(1), "."))
If Not theFileExtension = "LNK" Then
Exit Sub
End If
End If
Effect = vbDropEffectCopy
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Set m_menuBar = Nothing
Set m_taskList = Nothing
Unload m_dockPopup
Unload m_listMenu
Unload m_startButton
ReleaseGraphics
UnhookWindow Me.hWnd
Settings.Comit
ReleaseGraphics
m_layeredWindowProperties.Release
ExitApplication
End Sub
Private Sub Form_Resize()
If Not m_initialized Then Exit Sub
InitializeGraphics
CalculateTaskbandDimensions
End Sub
Sub CalculateTaskbandDimensions()
If m_TaskbandBitmap Is Nothing Then Exit Sub
'm_systemTray.Dimensions = CreateRectL(0, 0, Me.ScaleWidth - m_systemTray.Image.Width, 3)
m_taskbandDimensions.Width = m_TaskbandBitmap.Image.Width
m_taskbandDimensions.Height = m_TaskbandBitmap.Image.Height
m_taskbandDimensions.Left = Me.ScaleWidth - ACTUAL_ICON_SIZE - SEPERATOR_SIZE - m_taskbandDimensions.Width - m_clock.Width - 3
m_clock.X = Me.ScaleWidth - (m_clock.Width + SEPERATOR_SIZE)
m_clock.Y = 2
m_arrowPlacement.Left = m_clock.X - (ACTUAL_ICON_SIZE + SEPERATOR_SIZE)
m_menuBar.Dimensions = CreateRectL(Me.ScaleHeight, m_taskbandDimensions.Left - 50, 50, 0)
m_menuBar.Background = m_backgroundImage
m_taskbandDimensions.Top = 0
End Sub
Private Function IHookSink_WindowProc(hWnd As Long, _
msg As Long, _
wp As Long, _
lp As Long) As Long
'Dim bConsume As Boolean
Dim theWindow As Window
On Error GoTo Handler
If msg = WM_MOUSELEAVE Then
m_mouseTracking = False
HandleMouseLeave
ElseIf msg = m_Shell_Hook_Msg_ID Then
'wp = 32772 (for windows 8)
If wp = HSHELL_WINDOWACTIVATED Or wp = 32772 Then
HandleWindowActivated lp
ElseIf wp = HSHELL_FLASH Then
Set theWindow = m_taskList.GetWindowByHWND(lp)
If Not theWindow Is Nothing Then
theWindow.Flashing = True
End If
End If
ElseIf msg = WM_ACTIVATE Then
If wp = WA_ACTIVE Or wp = WA_CLICKACTIVE Then
If lp = m_systemTrayPopup.hWnd Then
m_ignoreTrayMenuSpawn = True
End If
End If
ElseIf msg = WM_DROPFILES Then
Dim hFilesInfo As Long
Dim szFileName As String
Dim wTotalFiles As Long
Dim wIndex As Long
hFilesInfo = wp
wTotalFiles = DragQueryFileW(hFilesInfo, &HFFFF, ByVal 0&, 0)
For wIndex = 0 To wTotalFiles
szFileName = Space$(1024)
If Not DragQueryFileW(hFilesInfo, wIndex, StrPtr(szFileName), Len(szFileName)) = 0 Then
Form_DragDropFile TrimNull(szFileName)
End If
Next wIndex
DragFinish hFilesInfo
End If
'If bConsume Then Exit Function
Handler:
' Just allow default processing for everything else.
IHookSink_WindowProc = InvokeWindowProc(hWnd, msg, wp, lp)
End Function
Private Function HandleMouseLeave()
m_menuBar.ResetSelector
End Function
Private Sub HandleWindowActivated(hWnd As Long)
If hWnd = 0 Then
Exit Sub
End If
If hWndBelongToUs(hWnd) Then
Exit Sub
End If
m_menuBar.PopulateFromhWnd hWnd
End Sub
Private Sub m_clock_onMouseLeaves()
m_dockPopup.Hide
End Sub
Private Sub m_clock_onPopup(ByVal szText As String)
If Not m_dockPopup.Visible Then
m_dockPopup.Top = Me.Top + Me.Height
m_dockPopup.ShowTextPopup szText, m_clock.X + (m_clock.Width / 2)
End If
End Sub
Private Sub m_listMenu_onClosed()
'Set m_lastProcessShowcased = Nothing
Set m_lastSelectedProcess = Nothing
End Sub
Private Sub m_listMenuPointer_onRightClick(theItem As Object)
Dim targetWindow As Window
Dim theMenuHandle As Long
Dim thisMenu As clsMenu
Dim sysCmdID As Long
Dim currentCursorPosition As Win.POINTL
Set targetWindow = theItem
If targetWindow.IsHung Then Exit Sub
GetCursorPos currentCursorPosition
theMenuHandle = GetSystemMenu(targetWindow.hWnd, 0)
Set thisMenu = CreateSystemMenu(theMenuHandle, targetWindow.WindowState)
SetForegroundWindow m_listMenuPointer.hWnd
sysCmdID = thisMenu.ShowMenu(m_listMenuPointer.hWnd)
Select Case sysCmdID
Case SC_RESTORE
ShowWindow targetWindow.hWnd, SW_SHOWNORMAL
Case SC_MINIMIZE
ShowWindow targetWindow.hWnd, SW_SHOWMINIMIZED
Case SC_MAXIMIZE
ShowWindow targetWindow.hWnd, SW_SHOWMAXIMIZED
Case SC_CLOSE
PostMessage targetWindow.hWnd, WM_CLOSE, 0&, 0&
Case Else
PostMessage targetWindow.hWnd, WM_SYSCOMMAND, ByVal sysCmdID, ByVal MAKELPARAM(currentCursorPosition.X, currentCursorPosition.Y)
End Select
End Sub
Private Sub m_menuBar_onChanged()
DrawTaskList
End Sub
Private Sub m_startButton_onMove(newX As Long, newY As Long)
newX = 0
newY = (m_menuBarSlice.Height / 2 - m_startButton.ScaleHeight / 2)
End Sub
Private Sub m_systemTray_onChange()
CalculateTaskbandDimensions
End Sub
Private Sub timEnumerateTasks_Timer()
Dim cursorPos As POINTL
GetCursorPos cursorPos
If Me.Left <> 0 Or Me.Top <> 0 Or Me.Width <> Screen.Width Or Me.ScaleHeight <> m_backgroundImage.Height Then
Me.Move 0, 0, Screen.Width, m_backgroundImage.Height * Screen.TwipsPerPixelY
End If
If cursorPos.X > (Me.Left + Me.Width) / (Screen.TwipsPerPixelX) Or cursorPos.X < (Me.Left / Screen.TwipsPerPixelX) Or cursorPos.Y > (Me.Top + Me.Height) / (Screen.TwipsPerPixelY) Or cursorPos.Y < (Me.Top / Screen.TwipsPerPixelY) Then
m_dockPopup.Hide
End If
'If m_systemTray.Dimensions.Left <> Me.ScaleWidth - m_systemTray.Image.Width Then
'CalculateTaskbandDimensions
'End If
m_taskList.Update Me.hWnd
m_menuBar.Update
'm_taskList.PrintProcesses
ResizeTaskBandIfNeeded m_taskList.Processes.Count
SetPositionNewProcesses
CopyAndSortVisibleList
DrawTaskList
End Sub
Sub DrawTaskList()
On Error GoTo Handler
Dim thisProcess As Process
Dim szDebugInfo As String
m_TaskbarBackgroundGraphics.Clear
m_TaskbandGraphics.Clear
'm_TaskbarBackgroundGraphics.Exclude m_menuBar.Dimensions
m_TaskbarBackgroundGraphics.Exclude RECTLtoF(m_menuBar.Dimensions)
'm_TaskbarBackgroundGraphics.DrawImage m_backgroundImage, 0, 0, Me.ScaleWidth, Me.ScaleHeight
SliceHelper.DrawSlices m_slices, m_TaskbarBackgroundGraphics, Me
m_TaskbarBackgroundGraphics.ResetExclusions