Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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.

  • *Gurus*
Posted

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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

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

  • 1 year later...
Posted

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

  • *Experts*
Posted

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.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted
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.
-Ben LaBore

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...