?? 23.txt
字號:
捕捉 MouseExit 事件
MouseDown、MouseUp、MouseMove。VB 似乎提供了很好的 Mouse 事件。但好象還缺少什么!對!還差 MouseExit(鼠標移出)事件。在 VB 中,我們要捕捉 MouseExit 事件,必須用 API 函數(shù):
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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -