VBGood网站全文搜索 Google

首页 - 经验之谈 - 捕捉 MoueExit 事件
发表评论(0)作者:, 平台:, 阅读:10434, 日期:2000-03-12
捕捉 MoueExit 事件

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 <= X) And (X <=Picture1.Width And (0 <=Y) And (Y <=Picture1.Height)

If MouseExit Then

SetCapture Picture1.hWnd



End If