|
-
Jun 6th, 2001, 02:10 PM
#1
Thread Starter
Junior Member
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...
-
Jun 6th, 2001, 03:10 PM
#2
Addicted Member
-
Jun 6th, 2001, 03:15 PM
#3
Addicted Member
Also, only case 1(Left), 2(Right) and 4(Middle) are valid - 3 and 5 won't occur
-
Jun 6th, 2001, 03:17 PM
#4
Thread Starter
Junior Member
Software for the next century...
-
Jun 6th, 2001, 03:52 PM
#5
Addicted Member
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.
-
Jun 6th, 2001, 04:03 PM
#6
Thread Starter
Junior Member
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...
-
Jun 6th, 2001, 09:13 PM
#7
Thread Starter
Junior Member
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...
-
Jun 6th, 2001, 09:25 PM
#8
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
-
Jun 6th, 2001, 09:34 PM
#9
Thread Starter
Junior Member
Yeah, you're right. What can I do to achieve the affect I want?
Software for the next century...
-
Jun 6th, 2001, 09:42 PM
#10
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
-
Jun 6th, 2001, 09:42 PM
#11
PowerPoster
edited...
Could u use an array on your toolbar?
Last edited by Beacon; Jun 6th, 2001 at 09:48 PM.
-
Jun 6th, 2001, 09:43 PM
#12
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 6th, 2001, 09:57 PM
#13
Thread Starter
Junior Member
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...
-
Jun 6th, 2001, 10:18 PM
#14
This is by no mean perfect not even very good but its a start:
VB Code:
Private Sub Toolbar1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Me.Caption = x & " , " & y
'1=0-330
'2=330-690
'3=690-1050
'about 345 each
tbnum = CInt((x / 345) + 0.5)
Label1.Caption = tbnum
Select Case tbnum
Case 1
'If tbnum = 1 Then
Toolbar1.Buttons(1).Caption = "One"
Toolbar1.Buttons(2).Caption = " "
Toolbar1.Buttons(3).Caption = " "
'End If
Case 2
'If tbnum = 2 Then
Toolbar1.Buttons(1).Caption = " "
Toolbar1.Buttons(2).Caption = "Two"
Toolbar1.Buttons(3).Caption = " "
'End If
Case 3
'If tbnum = 3 Then
Toolbar1.Buttons(1).Caption = " "
Toolbar1.Buttons(2).Caption = " "
Toolbar1.Buttons(3).Caption = "Three"
'End If
Case Else
Toolbar1.Buttons(1).Caption = " "
Toolbar1.Buttons(2).Caption = " "
Toolbar1.Buttons(3).Caption = " "
End Select
End Sub
I used a toolbar with three buttons as my sample.
Last edited by Edneeis; Jun 6th, 2001 at 10:39 PM.
-
Jun 6th, 2001, 10:36 PM
#15
Thread Starter
Junior Member
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...
-
Jun 6th, 2001, 11:20 PM
#16
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|