Solved

Connect the Toolbar buttons with the Statusbar

Posted on 1998-11-12
10
339 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

776 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