This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMenu.cls
139 lines (107 loc) · 3.35 KB
/
CMenu.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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "CMenu"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private colNames As New Collection
Private colIcons As New Collection
Private pForm As Form
Public Sub Initialize(frm As Form)
Dim ctrl As Control
Dim mItem As Menu
Dim c As String
Dim idx As String
On Error Resume Next
Set pForm = frm
With frm.Controls("vlmCtrl")
.UseCustomColors = True
.SetImageList frmMain.ilIcons
.AutoShowHelp = False
.ShowTooltip = False
.TootipStyle = vlRectangle
'.MenuBorder = Normal
'.HighlightAppearance = vlFlat
' XP Style
' .HighlightStyle = XP
' .MenuBackground = RGB(251, 251, 249)
' .DisabledTextColor = &HA5A5A5
' .textColor = vbBlack
' .HighlightedTextColor = vbBlack
' .MenuHighlight = RGB(191, 202, 217)
' .MenuHighlightBorder = RGB(113, 150, 240)
' .BitmapBackground = RGB(229, 229, 222)
' Windows Default
' .HighlightStyle = Plain
' .MenuBackground = frm.BackColor
' .DisabledTextColor = &H80000011
' .textColor = &H80000012
' .HighlightedTextColor = &H8000000E
' .MenuHighlight = &H8000000D
' .MenuHighlightBorder = &H8000000D
' .BitmapBackground = .MenuBackground
' Inherit from Windows
'.BitmapBackground = &H80000004
.BitmapBackground = frm.BackColor
.DisabledTextColor = &H80000011
.HighlightAppearance = vlFlat
.HighlightedTextColor = &H8000000E
.HighlightStyle = Plain
.MenuBackground = &H80000004 'menu bar
.MenuBarBackground = frm.BackColor
.MenuBorder = Normal
.MenuHighlight = &H8000000D
'.MenuHighlightBorder = .MenuHighlight
.textColor = &H80000007
End With
While colNames.Count
colNames.Remove 1
Wend
While colIcons.Count
colIcons.Remove 1
Wend
For Each ctrl In frm.Controls
If TypeOf ctrl Is Menu Then
Set mItem = ctrl
With mItem
idx = ""
idx = .Index
If LenB(idx) <> 0 Then idx = "|" + idx
c = FixCaption(.Caption)
If LenB(c) <> 0 Then colNames.Add .Name + idx, c
End With
End If
Next
End Sub
Public Property Get IconIndex(ByVal c As String) As Integer
On Error Resume Next
IconIndex = colIcons(c)
End Property
Public Property Let IconIndex(ByVal c As String, ByVal NewValue As Integer)
On Error Resume Next
colIcons.Add NewValue, c
End Property
Public Function Name(ByVal c As String) As String
On Error Resume Next
If LenB(c) = 0 Then Exit Function
Name = colNames(FixCaption(c))
End Function
Private Function FixCaption(ByVal c As String) As String
c = Replace(c, "-", "")
c = Replace(c, "/", "")
c = Replace(c, "\", "")
c = Replace(c, ">", "")
c = Replace(c, "<", "")
FixCaption = c
End Function
Private Sub Class_Terminate()
Set pForm = Nothing
End Sub