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.
Printable View
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.
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
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?
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