-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclsMRU.cls
183 lines (132 loc) · 3.4 KB
/
clsMRU.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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsMRU"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private colMRUFiles As New Collection
Private Num As Integer
Public Sub Add(file As String)
If colMRUFiles.count = 0 Then
colMRUFiles.Add file, UCase$(file)
Else
On Error Resume Next
colMRUFiles.Remove UCase$(file)
colMRUFiles.Add file, UCase$(file), 1
If colMRUFiles.count > Num Then
colMRUFiles.Remove colMRUFiles.count
End If
End If
End Sub
Public Sub Clear()
' *** Clears all files from the list.
Do While colMRUFiles.count > 0
colMRUFiles.Remove 1
Loop
End Sub
Public Property Get count() As Long
' *** Returns the number of files in the
' list.
count = colMRUFiles.count
End Property
Public Property Get ITem(i As Integer) As String
' *** Returns the nth item from the list
'
On Error GoTo ItemError
ITem = colMRUFiles(i)
Exit Property
ItemError:
ITem = ""
End Property
Public Sub Load(Optional AppName As Variant)
Dim v As Variant
'Dim i As Integer
Dim J As Integer
Dim AppN As String
v = GetAllSettings("Domain Manager Pro", "colMRUFiles")
Dim strData As String
Dim i As Long
For i = 1 To 5
strData = GetSetting("Domain Manager Pro", "colMRUFiles", CStr(i), "NONE")
If strData <> "NONE" Then
colMRUFiles.Add strData, strData
End If
Next
Exit Sub
If Not IsEmpty(v) Then
i = UBound(v, 1)
Me.Clear
colMRUFiles.Add v(i, 1), UCase$(v(i, 1))
For J = i - 1 To LBound(v, 1) Step -1
colMRUFiles.Add v(J, 1), UCase$(v(J, 1)), 1
Next J
Else
End If
End Sub
Public Property Get Number() As Integer
' *** Gets the maximum size of the list.
'
Number = Num
End Property
Public Property Let Number(i As Integer)
' *** Sets the maximum size of the list.
'
Num = i
End Property
Public Sub Remove(file As String)
On Error Resume Next
colMRUFiles.Remove UCase$(file)
End Sub
Public Sub Save(Optional AppName As Variant)
Dim i As Integer
Dim AppN As String
On Error Resume Next
AppN = "Domain Manager Pro"
DeleteSetting AppN, "colMRUFiles"
For i = 1 To colMRUFiles.count
SaveSetting AppN, "colMRUFiles", i, colMRUFiles(i)
Next i
End Sub
Public Sub Update(F As Form)
' *** Note: The form must contain a menu
' control array
' ***named mnuMRUFiles that is at least
' as big
' ***as Number.
Dim i As Long
On Error GoTo NextStep
For i = 1 To Num
F.mnuMRUFiles(i).Visible = False
Next i
NextStep:
On Error GoTo MenuEnd
If colMRUFiles.count > 0 Then
F.mnuMRUFiles(0).Visible = True
For i = 1 To colMRUFiles.count
F.mnuMRUFiles(i).Caption = colMRUFiles(i)
F.mnuMRUFiles(i).Visible = True
Next i
Do
F.mnuMRUFiles(i).Visible = False
i = i + 1
Loop
Else
i = 0
Do
F.mnuMRUFiles(i).Visible = False
i = i + 1
Loop
End If
MenuEnd:
End Sub
Private Sub Class_Initialize()
Num = 5
End Sub