MouseDown、MouseUp、MouseMove。VB 似乎提供了很好的 Mouse 事件。但好象还缺少什么!对!还差 MouseExit(鼠标移出)事件。在 VB 中,我们要捕捉 MouseExit 事件,必须用 API 函数: Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long 然后,我们可以在控件(以 Picture1 为例)的 MouseMove 事件上加上以下代码:
With Picture1 'Change this to the name of the control If Button = 0 Then If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then 'Mouse pointer is outside button, so let other controls receive 'mouseevents too: ReleaseCapture ' 放入鼠标离开的代码 Else ' Mouse pointer is over button, so we'll capture it, thus ' we'll receive mouse messages even if the mouse pointer is ' not over the button SetCapture .hwnd
' 放入鼠标进入的代码 End If  
|