找回密码
 立即注册
搜索
查看: 440|回复: 1

[VB]可以实现onMouseOut和onMouseOver的类

[复制链接]
发表于 2002-4-27 15:27:43 | 显示全部楼层 |阅读模式
  1. Public Event MouseIN(X As Long, Y As Long)
  2. Public Event MouseOUT(X As Long, Y As Long)
  3. Public Event MouseEnter()
  4. Public Event MouseLeave()

  5. Private IsMouseIn As Boolean
  6. Private mvarTheControl As Object

  7. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
  8. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

  9. Private Type POINTAPI
  10.         X As Long
  11.         Y As Long
  12. End Type

  13. Private Type RECT
  14.         Left As Long
  15.         Top As Long
  16.         Right As Long
  17.         Bottom As Long
  18. End Type

  19. Public Sub CheckMouse()
  20. Dim controlRect As RECT, pt As POINTAPI
  21. GetWindowRect mvarTheControl.hwnd, controlRect
  22. GetCursorPos pt
  23. If pt.X >= controlRect.Left And pt.X <= controlRect.Right And pt.Y >= controlRect.Top And pt.Y <= controlRect.Bottom Then
  24.     RaiseEvent MouseIN(pt.X, pt.Y)
  25.     If IsMouseIn <> True Then
  26.         IsMouseIn = True
  27.         RaiseEvent MouseEnter
  28.     End If
  29. Else
  30.     RaiseEvent MouseOUT(pt.X, pt.Y)
  31.     If IsMouseIn <> False Then
  32.         IsMouseIn = False
  33.         RaiseEvent MouseLeave
  34.     End If
  35. End If
  36. End Sub

  37. Public Property Set TheControl(ByVal vData As Object)

  38.     Set mvarTheControl = vData
  39.    
  40. End Property


  41. Public Property Get TheControl() As Object
  42.    
  43.     Set TheControl = mvarTheControl

  44. End Property
复制代码

126

主题

821

回帖

1265

积分

金牌会员

积分
1265
发表于 2002-4-28 23:29:01 | 显示全部楼层
好东西,我先保存了,
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|海浩社区

GMT+8, 2025-9-19 02:43 , Processed in 0.089985 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表