toolbar

is it possible at all to detect the mouse over event of a toolbar. say if the mouse is over a certain button, i want to do something. thanks!
foxhoundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VbmasterCommented:
Put this in the MouseMove event..

  Dim BButton As Button
 
  For Each BButton In Toolbar1.Buttons
    If (BButton.Left <= x) And (BButton.Left + BButton.Width >= x) Then
      If (BButton.Top <= y) And (BButton.Top + BButton.Height >= y) Then
        Me.Caption = BButton.Index
        Exit For
      End If
    End If
  Next

The caption of the window is changed according to what button the mouse is over.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
foxhoundAuthor Commented:
the code works great but how do i make the event to control the mouse is not on top of the toolbar anymore? thanks
0
VbmasterCommented:
What you could do is to add a private variable (i.e. m_ButtonOver), and set that value to the BButton.Index in that For Each..Next loop. Then add this code in the beginning of the MouseOver event, just before the For Each.. Next loop

  If (m_ButtonOver > 0) Then
    Set BButton = Toolbar1.Buttons(m_ButtonOver - 1)
    If (BButton.Left <= x) And (BButton.Left + BButton.Width >= x) And (BButton.Top <= y) And (BButton.Top + BButton.Height >= y) Then
      'Still over the same button, so quit this function now damn't!
      Set BButton = Nothing
      Exit Sub
    End If
    Set BButton = Nothing
  End If


And you will have to add the line

  m_ButtonOver = BButton.Index + 1

right after that "Me.Caption = BButton.Index" line you had, or whatever you have exchanged it to.
0
foxhoundAuthor Commented:
sorry to ask again, but i didn't quite get what the code does in the above. what i want is to change me.caption back to nothing if the mouse is not over the toolbar. the last code may work but o dunno how to use it with the previous code. thanks once again
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.