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 事件上加上以下代碼:
Dim MouseExit As Boolean
MouseOver = (0 $#@60;= X) And (X $#@60;="Picture1.Width)" And (0 $#@60;="Y)" And (Y $#@60;="Picture1.Height)$#@60;Br"$#@62; If MouseExit Then
........
SetCapture Picture1.hWnd
Else
........
ReleaseCapture
End If