首页 > 学院 > 开发设计 > 正文

捕捉MouseExit事件

2019-11-18 17:52:51
字体:
来源:转载
供稿:网友
MouseDown、MouseUp、MouseMove。VB似乎提供了很好的Mouse事件。但好象还缺少什么!对!还差MouseExit(鼠标移出)事件。在VB中,我们要捕捉MouseExit事件,必须用API函数:
PRivateDeclareFunctionSetCaptureLib"user32"(ByValhWndAsLong)AsLong
PrivateDeclareFunctionReleaseCaptureLib"user32"()AsLong
然后,我们可以在控件(以Picture1为例)的MouseMove事件上加上以下代码:

WithPicture1'Changethistothenameofthecontrol
IfButton=0Then
If(X<0)Or(Y<0)Or(X>.Width)Or(Y>.Height)Then
'Mousepointerisoutsidebutton,soletothercontrolsreceive
'mouseeventstoo:
ReleaseCapture
'放入鼠标离开的代码
Else
'Mousepointerisoverbutton,sowe'llcaptureit,thus
'we'llreceivemousemessagesevenifthemousepointeris
'notoverthebutton
SetCapture.hwnd

'放入鼠标进入的代码
EndIf->


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表