希望判断鼠标移出Treeview,原来打算从周围控件的mousemove来处理一下算了,结果旁边有个没有mousemove事件Webbrowser,所以能够告诉我得知鼠标移出Treeview的判断方法或得知鼠标在Webbrowser上移动的方法或其他任何可能的替代较为详细的方法(比如用一个图片框得到Webbrowser的设备场景图像临时代替一下Webbrowser等等)就行,谢谢了!
调试欢乐多
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
应为
h = WindowFromPoint(P.X, P.Y)
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate m_fCaptured As BooleanPrivate 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