Kenbuddy Posted July 23, 2002 Posted July 23, 2002 How do you create a toolbar with buttons that change image as you roll over them with the mouse? For example, the IE5 interface has black & white buttons on the toolbar, but when you roll over them individually, they show in color. The standard .NET toolbar only lets you specify a single image list. It does not let you specify separate image lists for enabled/disabled/mouseover button conditions. Furthermore, I can't seem to access any events (such as mouse enter or mouse hover) for the individual buttons in the toolbar. Thanks, Kenbuddy Quote
Kenbuddy Posted July 27, 2002 Author Posted July 27, 2002 Does anybody know how to read a mouse enter or mouse leave event for individual buttons within a toolbar? I can read these events for the entire toolbar itself, but not the individual buttons. Thanks. Quote
*Gurus* divil Posted July 28, 2002 *Gurus* Posted July 28, 2002 I don't think that will be possible, per se. Not with the standard toolbar control. You could subclass it and get the coordinates of the mouse over the control when it is moved, but you'd still have to map that to the buttons somehow. You're probably better off searching for somebody elses toolbar component which supports this functionality, or writing your own. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Kenbuddy Posted August 4, 2002 Author Posted August 4, 2002 I tried to create my own toolbar button by creating a class that inherits System.Windows.Forms.ToolBarButton. I was hoping to tinker around with it and figure out how to get it to respond to mouse enter and mouse leave events, but no luck. My test application would not compile after changing the reference to System.Windows.Forms.ToolBarButton (in the Windows Form Designer generated code) section of my form to the new class name I created. The ToolBarButton I'm assuming is a child control to the Toolbar. Can't I just modify the ToolBarButton, or do I have to tinker with the Toolbar itself? There's gotta be an easy way to do this. Thanks. Kenbuddy Quote
s_parsee Posted May 11, 2004 Posted May 11, 2004 any luck?? I tried to create my own toolbar button by creating a class that inherits System.Windows.Forms.ToolBarButton. I was hoping to tinker around with it and figure out how to get it to respond to mouse enter and mouse leave events, but no luck. My test application would not compile after changing the reference to System.Windows.Forms.ToolBarButton (in the Windows Form Designer generated code) section of my form to the new class name I created. The ToolBarButton I'm assuming is a child control to the Toolbar. Can't I just modify the ToolBarButton, or do I have to tinker with the Toolbar itself? There's gotta be an easy way to do this. Thanks. Kenbuddy Quote
*Experts* DiverDan Posted May 11, 2004 *Experts* Posted May 11, 2004 I don't know if this would help but if you add a tag value to each toolbar button then.. Private Sub ToolBar1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ToolBar1.MouseMove Dim x, i As Integer x = Me.PointToClient(Cursor.Current.Position).X For i = 0 To ToolBar1.Buttons.Count - 1 If x >= ToolBar1.Buttons(i).Rectangle.X + ToolBar1.Location.X _ And x <= ToolBar1.Buttons(i).Rectangle.X + ToolBar1.ButtonSize.Width + ToolBar1.Location.X Then Select Case ToolBar1.Buttons(i).Tag 'change image here End Select End If Next End Sub Ofcourse you'll need to also reset the button images back to their B&W images prior to the for loop. Anyway, it should be a start. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
blabore Posted May 12, 2004 Posted May 12, 2004 Though this might not be the way you want to go, the ActiveX toolbar control from the Windows Common controls in VB6 supports different images for mouseovers, etc. You could add this control to a .Net Windows Form project. Quote -Ben LaBore
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.