Click to See Complete Forum and Search --> : Left Click
Armadillo
Nov 9th, 1999, 05:17 AM
How can I make the click event code of a label execute only to a left mouse click? And I dont want to put the code in the mouse up and mouse down events.
cas21
Nov 9th, 1999, 05:27 AM
Use mouse_down event'
'If button = 2 then
'do whatever
end if
Compwiz
Nov 9th, 1999, 07:23 AM
You are gonna have to use MouseDown or MouseUp... My Recommendation:
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case Button
Case 1 'LEFT MOUSE BUTTON
MsgBox "Left Mouse Button Pressed"
Case 2 'RIGHT MOUSE BUTTON
MsgBox "Right Mouse Button Pressed"
End Select
End Sub
------------------
Tom Young, 14 Year Old
tyoung@stny.rr.com
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer
MartinLiss
Nov 9th, 1999, 07:41 AM
You should use VB's built in constants rather than "magic numbers" like 1 and 2, so substitute vbRightButton and vbLeftButton. They're self-documenting.
------------------
Marty
SteveS
Nov 9th, 1999, 11:20 AM
You can use the MouseClick Event, but some extra code is needed,
Declare the following function to get all keys pressed (including mouse buttons)
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Label1_Click
If GetAsyncKeyState(lngKeyToCheck) <> 0 then
'Do what you want
EndIf
End Sub
Replace "lngKeyToCheck" with the code const for the key you want to check for. In this case the Left Mouse Key.
Hope this helps,
Steve.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.