(35 pts) ActiveX - MouseOn / Off

I'm creating an ActiveX control that has the ability to be FLAT, but when you move your mouse over it, becomes 3D.

I can trap the MouseMove event to cause the button to become 3D, but how do you know when the mouse has moved off your ActiveX control to make it flat again?  Is there a way to trap the MouseMove event of the control's .Parent object to know that it no longer has the mouse over it?  Or is there an event of the UserControl that will tell me the mouse is exiting the control?

Thanks,

HATCHET
LVL 3
HATCHETAsked:
Who is Participating?
 
Erick37Connect With a Mentor Commented:
The UserControl can capture the mouse when it detects mousemoves.  When the mouse moves outside the UserControl, the mouse is released.  Example:

Private Declare Function SetCapture Lib "user32" _
    (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long

Private bCaptured As Boolean

Private Sub UserControl_MouseMove(Button As Integer, _
        Shift As Integer, X As Single, Y As Single)
    If Not bCaptured Then
        SetCapture hwnd
        bCaptured = True
        Debug.Print "Mouse In"
    End If
    If (X < 0) Or (X > ScaleWidth) Or _
        (Y < 0) Or (Y > ScaleWidth) Then
        Debug.Print "Mouse Out"
        ReleaseCapture
        bCaptured = False
    End If
End Sub
0
 
amit_panjwaniCommented:
u can use a picture control or a timer to get mouseovers

using timer
u will have to use getcursor api as well to get mouse co ordinates

the timer keeps on polling

secondly
u can use picture box

actually somebody had asked this question before as well
0
 
Erick37Commented:
P.S.
You also have to recapture the mouse in the click event:

Private Sub UserControl_Click()
    Debug.Print "Click"
    SetCapture hwnd
    bCaptured = True
End Sub
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Erick37Commented:
Correction in the code:

....
If (X < 0) Or (X > ScaleWidth) Or _
        (Y < 0) Or (Y > ScaleHeight) Then
....
0
 
HATCHETAuthor Commented:
Adjusted points to 35
0
 
HATCHETAuthor Commented:
Worked PERFECTLY !!!

Thanks a ton !      =D
0
All Courses

From novice to tech pro — start learning today.