Results 1 to 16 of 16

Thread: Mouse Over Toolbar

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Texas
    Posts
    27

    Question Mouse Over Toolbar

    I want to put text inside a label's caption when the user moves their mouse over a button in a toolbar. How can i do this? I have tried this code but get the following error message: "Invalid Qualifier." It highlights the Button in Button.Index on this error. What can I do?

    Private Sub tlbMain_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Select Case Button.Index

    Case 1
    lblInfo.Caption = "Something"
    Case 2
    lblInfo.Caption = "Something"
    Case 3
    lblInfo.Caption = "Update"
    Case 4
    lblInfo.Caption = "Help"
    Case 5
    lblInfo.Caption = "Exit"

    End Select
    End Sub
    Software for the next century...

  2. #2
    Addicted Member eer3's Avatar
    Join Date
    Sep 2000
    Location
    Ca
    Posts
    165

    Remove the .Index

    Select Case Button

  3. #3
    Addicted Member eer3's Avatar
    Join Date
    Sep 2000
    Location
    Ca
    Posts
    165
    Also, only case 1(Left), 2(Right) and 4(Middle) are valid - 3 and 5 won't occur

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Texas
    Posts
    27

    Why?

    Why won't they occur?
    Software for the next century...

  5. #5
    Addicted Member eer3's Avatar
    Join Date
    Sep 2000
    Location
    Ca
    Posts
    165
    The variable Button is referring to the button on the mouse that was clicked for the MouseMove Event.

    Here's how MSDN explains it...

    Button
    Integer value specifying a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating which buttons were being pressed at the time the event occurred.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Texas
    Posts
    27

    Ok...

    Then I did it wrong, what I want to happen it when a mouse cursor is moved over a TOOLBAR button, then I want some text to appear in a label. Obviously it's my fault for not explaining this better. How can I do this then?
    Software for the next century...

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Texas
    Posts
    27

    Unhappy Hmmm...

    Private Sub tlbMain_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Select Case Button

    Case 1
    lblInfo.Caption = "Something"
    Case 2
    lblInfo.Caption = "Something"
    Case 3
    lblInfo.Caption = "Update"
    Case 4
    lblInfo.Caption = "Help"
    Case 5
    lblInfo.Caption = "Exit"

    End Select
    End Sub

    This code still does not show the text in the label when the mouse moves over one of the buttons in the toolbar. Any ideas?
    Software for the next century...

  8. #8
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    that is becuse it is not refering to the toolbar button, but to the mouse button. Try your code, and hold down the left mouse button on one of the toolbar buttons. The label should run the code for Case 1.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Texas
    Posts
    27
    Yeah, you're right. What can I do to achieve the affect I want?
    Software for the next century...

  10. #10
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Off the top of my head, you can check the x, and y in the mousemove event,and set it up to react to that, but that can get pretty hinky and with more code than youy probably want.

    I think there is a way to use a variable dimensioned as an MSComctl.Button, but I'm not sure how.

    sorry
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  11. #11
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    edited...

    Could u use an array on your toolbar?
    Last edited by Beacon; Jun 6th, 2001 at 09:48 PM.

  12. #12
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by Beacon
    Dont be yellin at me this time if im wrong!
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Texas
    Posts
    27
    I think you're right crptcblade. I thought about that and maybe I could use the button.index. Not sure, lemme mingle around with the code and I'll post it when it works.
    Software for the next century...

  14. #14
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    This is by no mean perfect not even very good but its a start:
    VB Code:
    1. Private Sub Toolbar1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    2. Me.Caption = x & " , " & y
    3. '1=0-330
    4. '2=330-690
    5. '3=690-1050
    6. 'about 345 each
    7. tbnum = CInt((x / 345) + 0.5)
    8. Label1.Caption = tbnum
    9. Select Case tbnum
    10. Case 1
    11. 'If tbnum = 1 Then
    12.     Toolbar1.Buttons(1).Caption = "One"
    13.     Toolbar1.Buttons(2).Caption = " "
    14.     Toolbar1.Buttons(3).Caption = " "
    15. 'End If
    16. Case 2
    17. 'If tbnum = 2 Then
    18.     Toolbar1.Buttons(1).Caption = " "
    19.     Toolbar1.Buttons(2).Caption = "Two"
    20.     Toolbar1.Buttons(3).Caption = " "
    21. 'End If
    22. Case 3
    23. 'If tbnum = 3 Then
    24.     Toolbar1.Buttons(1).Caption = " "
    25.     Toolbar1.Buttons(2).Caption = " "
    26.     Toolbar1.Buttons(3).Caption = "Three"
    27. 'End If
    28. Case Else
    29.     Toolbar1.Buttons(1).Caption = " "
    30.     Toolbar1.Buttons(2).Caption = " "
    31.     Toolbar1.Buttons(3).Caption = " "
    32. End Select
    33. End Sub
    I used a toolbar with three buttons as my sample.
    Last edited by Edneeis; Jun 6th, 2001 at 10:39 PM.

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Texas
    Posts
    27

    Thanks

    It's definetley a start, didn't work well though, because my toolbar is in the midde of the form. But a good start, thanks.
    Software for the next century...

  16. #16
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Try this:

    I used 1 button so modify it for more than 1.

    Private Sub tb_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    If x > tb.Buttons(1).Left And x < tb.Buttons(1).Width Then
    Label1.Caption = "YOUR FIRST BUTTON"
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width