VB鼠标位置
如何让VB实现鼠标移动到一个位置然后窗体就关闭?注意不是VB6,最好可以定位鼠标在一定区域内的位置...
如何让VB实现鼠标移动到一个位置然后窗体就关闭?
注意不是VB6,最好可以定位鼠标在一定区域内的位置 展开
注意不是VB6,最好可以定位鼠标在一定区域内的位置 展开
2个回答
展开全部
你是说鼠标离开事件吗?
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub Object1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseOver As Boolean
'判断当前鼠标位置是否在Object1上
MouseOver = (0 <= X) And (X <= Object1.Width) And (0 <= Y) And (Y <= Object1.Height)
If MouseOver Then
' MouseOver Event
' 假如鼠标在Object1上, 则利用SetCapture将每一个鼠标事件都传递给Object1
' 并显示小精灵
小精灵.Visible = True
SetCapture Object1.hWnd
Else
' MouseLeave Event
' 假如鼠标不在Object1上, 则利用ReleaseCapture释放鼠标捕捉
' 并关闭显示小精灵
小精灵.Visible = False
ReleaseCapture
End If
End Sub
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub Object1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseOver As Boolean
'判断当前鼠标位置是否在Object1上
MouseOver = (0 <= X) And (X <= Object1.Width) And (0 <= Y) And (Y <= Object1.Height)
If MouseOver Then
' MouseOver Event
' 假如鼠标在Object1上, 则利用SetCapture将每一个鼠标事件都传递给Object1
' 并显示小精灵
小精灵.Visible = True
SetCapture Object1.hWnd
Else
' MouseLeave Event
' 假如鼠标不在Object1上, 则利用ReleaseCapture释放鼠标捕捉
' 并关闭显示小精灵
小精灵.Visible = False
ReleaseCapture
End If
End Sub
追问
是这样的:当鼠标放在button1上,那么button2就出现,就是这个意思
追答
哦 ,那你在button1的mousemove事件中写代码
button2.visible=true
或者用代码生成新的按钮也可以
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询