控件中有三个类:
OutlookBarButton类
该类实现了单个的Button实例,其中绘图不包括在这里。
基本成员如下:
Text:如果按钮作为大的按钮显示的时候,文字会显示在上面。如果,按钮显示在最下方,作为小的按钮显示,这些文字会作为Tooltip显示。
Visible:指示按钮是否可见,可以在运行过程中,动态地设置。
Allowed:当设置为False时,这个按钮不可见。在运行的时候,你不可以访问它,可以阻止特定的用户只允许访问特定按钮。
Image:显示在按钮上的图片。最好是24x24或更大的图标。
Rectangle:只在assembly可设。
OutlookBarButtonCollection类:
它继承于CollectionBase,是上述Button的集合。代码的使用如下:
Code:
Dim newButton as New Altea.OutlookBarButton
With newButton
.Text="my button"
.Visible=False
.Image=My.Resources.myImage
End With
me.OutlookBar1.Buttons.Add(newButton)
或者,使用重载的构造函数:
Code:
Me.OutlookBar1.Buttons.Add(New Altea.OutlookBarButton("my button", My.Resources.myImage))
OutlookBar类
它是本控件的主类,继承于System.Windows.Forms.Control。目前,它有一个Renderer 属性,可以设置为Office2003 或 Office2007;将来,它还会可以设置成Custom。
你可以在代码中选择一个Button:
Code:
Me.OutlookBar1.Buttons("Journal").Selected = True
该类处理了主要的事件,例如MouseMove, MouseDown, MouseLeave等等。绘图也是在这里实现的。OutlookBar 类里还决定按钮的ButtonState 属性,从而,控制按钮如何执行用户的动作。
Code:
Friend Enum ButtonState
Passive
Hovering
Selected
End Enum
[绘制]
在绘制按钮的时候,我们通常涉及到的区域如下:
