自己做MouseIn/MouseOut事件的BUG
自己写了一个控件,想实现MouseIn/MouseOUt事件利用SetCapture和ReleaseCapture来实现的
在调试时,如果在控件的MouseIn代码中加入
MsgBox "I'm IN"
则原控件中的MouseOut事件不会再被触发了
''''控件代码实现部分
Public Declare Function SetCapture Lib "user32 " (ByVal hwnd As Long) As Long
Public Declare Function ReleaseCapture Lib "user32 " () As Long
Public Event MouseIn()
Public Event MouseOut()
............
Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > 0 And X < Text1.Width And Y > 0 And Y < Text1.Height Then
SetCapture Text1.hwnd '鼠标捕获
Text1.BackColor = vbRed
RaiseEvent MouseIn
Debug.Print "IN"
Else
Text1.BackColor = vbWhite
ReleaseCapture '释放鼠标捕获
RaiseEvent MouseOut
Debug.Print "OUT"
End If
End Sub
不知有什么好的解决方案不?