Results 1 to 2 of 2

Thread: VB - Trapping mouse up event anywhere in application?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    111

    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

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: VB - Trapping mouse up event anywhere in application?

    Yes, you can do that and here is a quick sample:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetAsyncKeyState Lib "user32" _
    4.     (ByVal vKey As Long) As Integer
    5.  
    6. Private Const GAKS_KEYDOWN = &H8000
    7.  
    8. Private Sub Form_Load()
    9.     Timer1.Interval = 100
    10. End Sub
    11.  
    12. Private Sub Timer1_Timer()
    13.  
    14.     If GetAsyncKeyState(vbLeftButton) And GAKS_KEYDOWN Then
    15.         Me.Caption = "Left Button Down!"
    16.     ElseIf GetAsyncKeyState(vbLeftButton) Or GAKS_KEYDOWN Then
    17.         Me.Caption = "Left Button Up!"
    18.     End If
    19.  
    20. 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
  •  



Click Here to Expand Forum to Full Width