Solved

Connect the Toolbar buttons with the Statusbar

Posted on 1998-11-12
10
342 Views
Last Modified: 2010-04-30
I have a Toolbar, and I want help-text to be shown in the statusbar when the mouse moves over the different buttons on the toolbar. I've tried something like:

Private Sub Toolbar1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

Select Case Button.Key
    Case "New"
        Statusbar1.Panels(1).Text = "Create a new document"
    Case "Open"
        Statusbar1.Panels(1).Text = "Öppna dig nu"
End Select
End Sub

It gives me "invalid qualifier" error for the "Button", what should I use to check if the mouse moves over those buttons?
0
Comment
Question by:slobstar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1444497
Take a look at the hottrack tools from the microsoft premium side.
premium.microsoft.com/browse.asp
0
 
LVL 1

Expert Comment

by:tjp
ID: 1444498
Private Sub Toolbar1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

Select Case x \ Toolbar1.ButtonWidth
    Case 0
        Statusbar1.Panels(1).Text = "Create a new document"
    Case 1
        Statusbar1.Panels(1).Text = "Öppna dig nu"
End Select

End Sub

------------------------------------
Button is an integer which refers to the mouse button which is currently being pressed.  It is not an object referring to which button on the toolbar you are currently mousing over.  In order to figure that out you must instead take the x-value of the mouse location and divide it by the width of a single button, discarding the remainder ("\" operator).  This presumes that you will not be doing any API calls to resize each button individually.


0
 
LVL 1

Author Comment

by:slobstar
ID: 1444499
I might be slow, but can you give me a more specific answer?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:schild
ID: 1444500
Sub FindToolbarButtons ( )


    Dim x As Button
    Dim Index as Integer
   
    For Each x In Toolbar1.Buttons
        ButtonsPosArray[Index] = x.Left
    Next

End Sub

Now you can now where the mouse is

0
 
LVL 1

Author Comment

by:slobstar
ID: 1444501
tjp, give me the same answer and you'll get the points, I didn't have time to test your function yesterday, that's why I rejected, it works perfect. Thanks.
0
 
LVL 1

Expert Comment

by:ajmendes
ID: 1444502
Hi,
i think that this code is a more bullet proof.
I used the tooltip text of each toolbar button for this example.

Private Sub Toolbar1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

    If (x \ Toolbar1.ButtonWidth) <= Toolbar1.Buttons.Count - 1 Then
        StatusBar1.Panels(1).Text = Toolbar1.Buttons((x \ Toolbar1.ButtonWidth) + 1).ToolTipText
    Else
        StatusBar1.Panels(1).Text = ""
    End If
   
End Sub

0
 
LVL 1

Author Comment

by:slobstar
ID: 1444503
Thanks! It works great, but rewrite it so that I can write whatever I want + take into consideration that I might be using "seperators" if I do, all buttons won't be the same size.
0
 
LVL 1

Accepted Solution

by:
tjp earned 50 total points
ID: 1444504
Option Explicit

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    StatusBar1.Panels(1).Text = ""

End Sub

Private Sub StatusBar1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    StatusBar1.Panels(1).Text = ""

End Sub

Private Sub Toolbar1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim i As Integer
   
    For i = 1 To Toolbar1.Buttons.Count
        With Toolbar1
            If (x < (.Buttons(i).Left + .Buttons(i).Width)) And _
                (y < (.Buttons(i).Top + .Buttons(i).Height)) Then
                StatusBar1.Panels(1).Text = .Buttons(i).ToolTipText
                Exit Sub
            End If
        End With
    Next
    StatusBar1.Panels(1).Text = ""
End Sub


-------------------------------------------------------------
This should do everything you asked for...
0
 
LVL 1

Expert Comment

by:tjp
ID: 1444505
If you don't want it to use the Tooltip property, just put the text that you do want into the Tag property instead.  Nothing else uses the Tag property, so you are free to put anything you want in there when you define the toolbar.

Then change this line:
StatusBar1.Panels(1).Text = .Buttons(i).ToolTipText

to:
StatusBar1.Panels(1).Text = .Buttons(i).Tag

and you're all set.
0
 
LVL 1

Author Comment

by:slobstar
ID: 1444506
Do you know how to do the same for the menus? The I would really appreciate a e-mail to:   slobstar@mindless.com
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB6 - Convert HH:MM into Decimal 8 76
clicking a shape in a frame array vb6 3 55
Dinamic report to Crosstab query 9 60
transition to visual .net from vb6 5 81
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question