|
楼主 |
发表于 2014-3-1 15:25
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
【类模块ClsButton 代码】- Option Explicit
- Public WithEvents iLabel As MSForms.Label
- Public WithEvents labMenu As MSForms.Label
- Private Sub iLabel_Click()
- Dim clt As Control, i As Integer
- For Each clt In Main.Controls '标签属性还原
- If clt.Name Like "labButton*" Then
- clt.BackColor = &H8000000F
- clt.Font.Size = 10
- clt.ForeColor = &HC0C000
- End If
- If clt.Name Like "labMenu*" Then
- clt.Caption = ""
- clt.Visible = False
- End If
- Next
- Rem 设置选中标签 labButton 的属性
- Dim Index As Integer
- Index = Mid(iLabel.Name, 10, Len(iLabel.Name) - 9)
- With Main.Controls("labButton" & Index)
- .BackColor = &H80000016
- .Font.Size = 12
- .ForeColor = &HC0&
- Key1 = .Caption '获取主菜单名称
- End With
- Main.labView.Caption = Key1
- Rem 修改九宫格labMenu标签属性
- Dim arr, k As Integer, myPath As String
- arr = Sheet2.UsedRange
- For i = 1 To UBound(arr)
- If arr(i, 2) = Key1 Then
- myPath = ThisWorkbook.Path & "\Image" & Key1 & "" & arr(i, 3) & ".ico"
- With Main.Controls("labMenu" & arr(i, 4))
- .Caption = arr(i, 3)
- .Picture = LoadPicture(myPath)
- .Visible = True
- End With
- End If
- Next
- End Sub
- Private Sub labMenu_Click()
- Main.labView.Caption = Key1 & "" & Key2
- MsgBox "现在运行【" & Key2 & "】程序", vbInformation, Key2
- End Sub
- Private Sub labMenu_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
- Dim ctl As Control, Index As Integer
- For Each ctl In Main.Controls
- If ctl.Name Like "labMenu*" Then
- ctl.Font.Size = 10
- ctl.SpecialEffect = fmSpecialEffectFlat
- End If
- Next
- Index = Mid(labMenu.Name, 8, Len(labMenu.Name) - 7)
- With Main.Controls("labMenu" & Index)
- .Font.Size = 12
- .SpecialEffect = fmSpecialEffectRaised
- End With
- Key2 = labMenu.Caption
- End Sub
复制代码
|
|