Private Sub Form_Resize() XPmenu.Height =
Me.ScaleHeight End
Sub 当窗体的大小发生改变时候,同时也自动改变ctlExplorerBar的大小。通常只是改变ctlExplorerBar显示的高度,而宽度是不改变的,就像XP资源管理器中一样。
第四步:编写代码,实现ctlExplorerBar的事件相应。
①编写ctlExplorerBar的分栏的打开、收起事件,代码如下:
Private Sub XPmenu_Collapse(ByVal Index As Integer) Me.Caption =
"收起 " & Index End Sub
Private Sub XPmenu_Expand(ByVal Index
As Integer) Me.Caption = "展开 " & Index End
Sub 从上面的代码中我们可以看到,ctlExplorerBar提供了两个点击的事件,在这里的示例中我们把事件的相应放映在窗体标题栏中,当点击分栏时候,窗体标题栏就会显示收起或者展开哪一个分栏。
②添加点击分栏中项目的事件。
Private Sub XPmenu_SubItemClick(ByVal Index As Integer, ByVal
SubItemIndex As Integer) Me.Caption = "单击 " & Index & " 在 "
& SubItemIndex & " (" & XPmenu.SubItem(Index, SubItemIndex)
& ")" Me.Icon = XPmenu.SubItemIcon(Index, SubItemIndex) End
Sub 当用户点击分栏中的某个项目时,窗体的标题栏显示项目的Index以及其所在分栏。上面的代码告诉你怎样使用项目的点击响应,对于你的实际应用是很有用的。