I'm trying to make a custom control based on a PictureBox control.
Want to add something like a toolbar that must be hidden until the mouse is moved over the PictureBox when the toolbar must be made visible or slided into view. When the mouse is moved of the PictureBox the toolbar must be made invisible or slided back out of view. (Any ideas how to do this will also be appreciated.)
How do I detect when the mouse moves onto the PictureBox and off the PictureBox again?
Found the following on the board:
but it only detects the mouse going onto the control. When the mouse moves off the control it's not detected.
Want to add something like a toolbar that must be hidden until the mouse is moved over the PictureBox when the toolbar must be made visible or slided into view. When the mouse is moved of the PictureBox the toolbar must be made invisible or slided back out of view. (Any ideas how to do this will also be appreciated.)
How do I detect when the mouse moves onto the PictureBox and off the PictureBox again?
Found the following on the board:
Code:
Option Explicit
Private Declare Function Mouse_Enter Lib "user32" Alias "SetCapture" (ByVal hwnd As Long) As Long
Private Declare Function Mouse_Leave Lib "user32" Alias "ReleaseCapture" () As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static CtrMov As Boolean
With Command1
If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
Mouse_Leave
CtrMov = False
Debug.Print "Leaving"
Else
Mouse_Enter .hwnd
If CtrMov = False Then
CtrMov = True
Debug.Print "Entering"
End If
End If
End With
End Sub