如何卸载或关闭弹出式菜单
我的弹出式菜单动态加载许多菜单项请问高手,怎样卸载或关闭弹出式菜单?谢谢!
我的意思,再次打开弹出式菜单,重新加载菜单项。
Option Explicit Public PopMenuIndex As String '指示当前菜单是由哪个按钮触发的 Private Sub Command1_Click() '1号按钮 Call ClearPopMenuList '清原理菜单项 PopMenuIndex = 1 '1号按钮生成菜单 '-------菜单项--------- PopMenuList(0).Caption = "菜单A0" Load PopMenuList(1) PopMenuList(1).Caption = "菜单A1" Load PopMenuList(2) PopMenuList(2).Caption = "菜单A2" PopupMenu PopMenu, , Command1.Left, Command1.Top + Command1.Height '弹出菜单并定位 End Sub Public Sub ClearPopMenuList() '清除菜单内容 Dim i As Long For i = PopMenuList.Count - 1 To 1 Step -1 Unload PopMenuList(i) Next i PopMenuList(0).Caption = "<无>" End Sub Private Sub Command2_Click() '2号按钮 Call ClearPopMenuList '清原理菜单项 PopMenuIndex = 2 '2号按钮生成菜单 '-------菜单项--------- PopMenuList(0).Caption = "菜单B0" Load PopMenuList(1) PopMenuList(1).Caption = "菜单B1" Load PopMenuList(2) PopMenuList(2).Caption = "菜单B2" PopupMenu PopMenu, , Command2.Left, Command2.Top + Command2.Height End Sub Private Sub PopMenuList_Click(Index As Integer) '菜单事件 Select Case PopMenuIndex Case 1 '1号按钮 Select Case Index Case 0 MsgBox "1号按钮0号菜单" Case 1 MsgBox "1号按钮1号菜单" Case Else MsgBox PopMenuList(Index).Caption End Select Case 2 '2号按钮 MsgBox "2号按钮" & PopMenuList(Index).Caption End Select End Sub