# Code to Capture Mouse_Exit

Posted by kingkong on July 12, 1998 at 16:12:57:

In Reply to: 请问如何 当mouse 移到 按钮上时有浮动的效果! posted by 阿忠 on July 12, 1998 at 00:25:17:

Use this code to capture Mouse_exit:
Writen in Chinese GB code and from:
http://www.nease.net/~jackyyin
====================================

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
MouseExit = (0 <= X) And (X <= Picture1.Width) And (0 <= Y) And (Y <= Picture1.Height)
If MouseExit Then
' do somthing
SetCapture Picture1.hWnd
Else
' do songthing
ReleaseCapture
End If

Follow Ups: