如何得知鼠标移出Treeview?具体情况请见帖子内容。

kmzs 2004-04-28 10:32:23
希望判断鼠标移出Treeview,原来打算从周围控件的mousemove来处理一下算了,结果旁边有个没有mousemove事件Webbrowser,所以能够告诉我得知鼠标移出Treeview的判断方法或得知鼠标在Webbrowser上移动的方法或其他任何可能的替代较为详细的方法(比如用一个图片框得到Webbrowser的设备场景图像临时代替一下Webbrowser等等)就行,谢谢了!
...全文
56 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hisofty 2004-04-29
  • 打赏
  • 举报
回复
试试wm_mouseleave消息
kmzs 2004-04-29
  • 打赏
  • 举报
回复
——不过得自己声明API和定义变量类型哦。。。
kmzs 2004-04-29
  • 打赏
  • 举报
回复
kissoflife(明月高楼休独倚,酒入愁肠,化作相思泪!)的方法也可以!
supergreenbean 2004-04-28
  • 打赏
  • 举报
回复
当然,最好再加一句obj.Parent.ScaleMode=vbTwips
supergreenbean 2004-04-28
  • 打赏
  • 举报
回复
Option Explicit
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long

Private m_fCaptured As Boolean

Private Sub TreeView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim obj As TreeView
Set obj = TreeView1
If m_fCaptured Then
With obj
If x < 0 Or y < 0 Or x > .Width Or y > .Height Then
Debug.Print "out"
ReleaseCapture
m_fCaptured = False
End If
End With
Else
SetCapture obj.hwnd
m_fCaptured = True
End If
End Sub
wumy_ld 2004-04-28
  • 打赏
  • 举报
回复
h = WindowFromPoint(lX, lY)
应为
h = WindowFromPoint(P.X, P.Y)
wumy_ld 2004-04-28
  • 打赏
  • 举报
回复
在计时器里面加如下代码
Private Sub Timer1_Timer()
Dim P As POINTAPI, h As Long

’获取鼠标当前位置的坐标,以屏幕为坐标系
GetCursorPos P

’获取当前鼠标所在点所属窗口的句柄
h = WindowFromPoint(lX, lY)

if h<>TreeView1.hWnd then
msgbox "bye"
end if
End Sub


kmzs 2004-04-28
  • 打赏
  • 举报
回复
有详细一点的代码或范例更好,谢了。。。

7,763

社区成员

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

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