Option Compare Database
Option Explicit
'----------------------------------------------------------
'clsRibbon类
'相关 : clsRibbonControl类/modRibbonPublic模块
'日期 : 2009.05.02
'作者 : 朱亦文
'目的 :
'----------------------------------------------------------
Public Name As String
Public Ribbon As IRibbonUI
Public Ctrls As New Collection
Public Property Get Controls(controlName As String) As clsRibbonControl
On Error GoTo ErrControls
Dim i As Integer
Dim n As Integer
' 在控件集合中搜索控件是否存在,如果不存在,则添加之
For i = 1 To Ctrls.count
If controlName = Ctrls(i).Name Then
n = i
Exit For
End If
Next i
If n = 0 Then
' 如果控件不在集合中,则添加,并赋默认值
Dim NewCtrl As New clsRibbonControl
NewCtrl.Enabled = True
NewCtrl.Visible = True
NewCtrl.Label = ""
NewCtrl.Name = controlName
NewCtrl.image = ""
Ctrls.Add NewCtrl, controlName
Set Controls = NewCtrl ' 返回控件
Else
Set Controls = Ctrls(n) ' 返回控件
End If
Dim r As IRibbonUI
If Name = "" Then
Set r = Ribbons(1).Ribbon
Else
Set r = Ribbons(Name).Ribbon
End If
r.InvalidateControl controlName ' 刷新控件
Exit Property
ErrControls:
Debug.Print Err.Number, Err.Description
Resume Next
End Property