VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create GetMouseFocus / LostMouseFocus in yours controls (new version)

by Mauricio David (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 4th February 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Create GetMouseFocus / LostMouseFocus in yours controls (new version)

API Declarations


Public Declare Function ReleaseCapture Lib "user32" () As Long


Rate Create GetMouseFocus / LostMouseFocus in yours controls (new version)



'form with the name Command1

Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static CtrMov As Boolean
With Command1 'Change this 'Command1' to your control name
    If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
        ReleaseCapture
        CtrMov = False
        
        'Put here your code to LostMouseFocus
        'For example:
        Me.Print "LostMouseFocus"
        
    Else
        SetCapture .hwnd
        If CtrMov = False Then
            CtrMov = True
                        
            'Put here your code to GetMouseFocus
            'For example:
            Me.Print "GetMouseFocus"
        
        End If
    End If
End With
End Sub


Download this snippet    Add to My Saved Code

Create GetMouseFocus / LostMouseFocus in yours controls (new version) Comments

No comments have been posted about Create GetMouseFocus / LostMouseFocus in yours controls (new version). Why not be the first to post a comment about Create GetMouseFocus / LostMouseFocus in yours controls (new version).

Post your comment

Subject:
Message:
0/1000 characters