如何判断鼠标移出事件?

zerg2001 2002-09-09 08:23:54
用户控件,当鼠标在上方时突出显示,鼠标移出则回复正常状态。
如果用Form的Mouse move 是可以实现,有没有其他的方法?
...全文
157 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
haigenwong 2002-09-14
  • 打赏
  • 举报
回复
同意楼上的,但有一点,如果没句柄控件,上面的就不能用,这个问题我几乎在个个vb网战都有得解答,而且在csdn中已经看见过几次,为何还是有人问的,希望各位在提出问题之前,用本站的搜索查一下再问问题,这样可以减少开销,不是的话,我打开某一个问题的话,刚刚回答完,再刷新网页,那条问题已经不知去了哪里去(去了后面几页去了,前后才不到一分钟)
laisiwei 2002-09-14
  • 打赏
  • 举报
回复
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 事件上加上以下代码:

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
zerg2001 2002-09-14
  • 打赏
  • 举报
回复
TO: watt(瓦特)
这是个好方法,可以试试,你是把Time间隔设成多少?
watt 2002-09-09
  • 打赏
  • 举报
回复
Use Time Control
hillmanweb 2002-09-09
  • 打赏
  • 举报
回复
用API函数捕捉

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧