forked from lee-soft/ViStart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContextMenuHelper.bas
80 lines (59 loc) · 2.37 KB
/
ContextMenuHelper.bas
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
Attribute VB_Name = "ContextMenuHelper"
Option Explicit
Private m_logger As SeverityLogger
Private Property Get Logger() As SeverityLogger
If m_logger Is Nothing Then
Set m_logger = LogManager.GetLogger("ContextMenuHelper")
End If
Set Logger = m_logger
End Property
'This module is a generic context menu builder for files shown in ViStart
Public Function BuildGenericFileContextMenu(ByVal szFilePath As String) As frmVistaMenu
On Error GoTo Handler
Dim newContextMenu As frmVistaMenu
Set newContextMenu = New frmVistaMenu
Set BuildGenericFileContextMenu = newContextMenu
newContextMenu.AddItem GetPublicString("strOpen"), "OPEN", True
newContextMenu.AddItem GetPublicString("strRunAsAdmin"), "RUNASADMIN"
newContextMenu.AddItem ""
If Settings.Programs.ExistsInPinned(szFilePath) Then
newContextMenu.AddItem GetPublicString("strUnpinToStartMenu"), "TOGGLEPIN"
Else
newContextMenu.AddItem GetPublicString("strPinToStartMenu"), "TOGGLEPIN"
End If
If FileExists(szFilePath) Then
newContextMenu.AddItem ""
newContextMenu.AddItem GetPublicString("strProperties"), "PROPERTIES"
End If
Exit Function
Handler:
Logger.Error Err.Description, "BuildGenericFileContextMenu"
End Function
Public Function GenericFileContextMenuHandler(ByVal szCommand As String, ByVal szFilePath As String)
On Error GoTo Handler
Dim thisProgram As clsProgram
Dim theBaseMenu As frmStartMenuBase
Dim theRecentPrograms As frmFreq
Set theBaseMenu = FindFormByName("frmStartMenuBase")
Set theRecentPrograms = FindFormByName("frmFreq")
Select Case szCommand
Case "OPEN"
Settings.Programs.UpdateByProgramPath szFilePath
SelectBestExecutionMethod szFilePath
theRecentPrograms.PopulateItems
Case "RUNASADMIN"
theBaseMenu.CloseMe
ShellEx szFilePath, "runas"
Settings.Programs.UpdateByProgramPath szFilePath
theRecentPrograms.PopulateItems
Case "TOGGLEPIN"
Settings.Programs.TogglePin_ElseAddToPin_ByProgram CreateProgramFromPath(szFilePath)
theRecentPrograms.PopulateItems
Case "PROPERTIES"
theBaseMenu.CloseMe
ShellEx szFilePath, "properties"
End Select
Exit Function
Handler:
Logger.Error Err.Description, "GenericFileContextMenuHandler"
End Function