Solved

Connect the Toolbar buttons with the Statusbar

Posted on 1998-11-12
10
331 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
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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

706 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now