|
-
Aug 6th, 2001, 01:54 PM
#1
Thread Starter
Frenzied Member
Capturing mouse click
I need to check if the user has clicked the mouse at the beginning of a loop, I know this should be pretty easy but can't seem to do it without activating the forms mouse_down event.
Cheers.
-
Aug 6th, 2001, 03:36 PM
#2
You can use the GetAsyncKeyState() API to find out if a Mouse Button is being depressed, however, if the mouse is over a form or control, it will still Trigger the Mouse_Down event, the only way to stop the event triggering would be to subclass the form and discard the appropriate message(s).
Example of GetAsyncKeyState():
VB Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_LBUTTON = &H1
Private Sub Command1_Click()
If GetAsyncKeyState(VK_LBUTTON) Then
Debug.Print "Mouse Button Pressed."
End If
End Sub
-
Aug 6th, 2001, 05:27 PM
#3
Thread Starter
Frenzied Member
As I'm also using a mouse click to start the loop, how can i make this first click be ignored by GetAsyncKeyState(VK_LBUTTON)?
I've tried assigning GetAsyncKeyState(VK_LBUTTON) to a variable first but this still doesn't work.
Any ideas?
-
Aug 6th, 2001, 06:02 PM
#4
So you want to ignore the first click, and after that, than start it?
Try this:
VB Code:
Private Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Long) As Integer
Private Const VK_LBUTTON = &H1
Dim FirstClick As Boolean
Private Sub Command1_Click()
If FirstClick = False Then FirstClick = True: Exit Sub
If FirstClick = True Then
If GetAsyncKeyState(VK_LBUTTON) Then
Debug.Print "Mouse Button Pressed."
End If
End If
End Sub
Private Sub Form_Load()
FirstClick = False
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
|