VB - Trapping mouse up event anywhere in application?
Hi All
Can anyone tell me how you can easily and efficiently trap the "mouse up" event anywhere in an application without having to use the individual mouse up events for each form and control? I would like to apply some general code for every time the left mouse button goes up! Is it possible?
Pobo
Re: VB - Trapping mouse up event anywhere in application?
Yes, you can do that and here is a quick sample:
VB Code:
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Long) As Integer
Private Const GAKS_KEYDOWN = &H8000
Private Sub Form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbLeftButton) And GAKS_KEYDOWN Then
Me.Caption = "Left Button Down!"
ElseIf GetAsyncKeyState(vbLeftButton) Or GAKS_KEYDOWN Then
Me.Caption = "Left Button Up!"
End If
End Sub