MouseDown、MouseUp、MouseMove。VB似乎提供了很好的Mouse事件。但好象还缺少什么!对!还差MouseExit(鼠标移出)事件。在VB中,我们要捕捉MouseExit事件,必须用API函数:
PrivateDeclareFunctionSetCaptureLib”user32″(ByValhWndAsLong)AsLong
PrivateDeclareFunctionReleaseCaptureLib”user32″()AsLong
然后,我们可以在控件(以Picture1为例)的MouseMove事件上加上以下代码:
WithPicture1Changethistothenameofthecontrol
IfButton=0Then
If(X<0)Or(Y<0)Or(X>.Width)Or(Y>.Height)Then
Mousepointerisoutsidebutton,soletothercontrolsreceive
mouseeventstoo:
ReleaseCapture
放入鼠标离开的代码
Else
Mousepointerisoverbutton,sowellcaptureit,thus
wellreceivemousemessagesevenifthemousepointeris
notoverthebutton
SetCapture.hwnd
放入鼠标进入的代码
EndIf->