vb 鼠标放在图片上换图片
其实我是想实现按钮的功能.把当鼠标移到一个图片上时这个图片换成另一张,移走时又换回来!!不管用什么方法只要是在图片上实现就OK.鼠标移走的时候它不会变啊?!?!?!...
其实我是想 实现按钮的功能.
把当鼠标移到 一个 图片上时这个图片换成另一张,移走时又换回来!!
不管用什么方法只要是在图片上实现就OK.
鼠标移走的时候 它不会变啊?!?!?! 展开
把当鼠标移到 一个 图片上时这个图片换成另一张,移走时又换回来!!
不管用什么方法只要是在图片上实现就OK.
鼠标移走的时候 它不会变啊?!?!?! 展开
2个回答
展开全部
新建一个资源文件,添加两个位图资源,资源号分别为101,102.
Private Sub Form_Load()
Picture1.Picture = LoadResPicture(102, 0)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Picture = LoadResPicture(102, 0)
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Picture = LoadResPicture(101, 0)
End Sub
'---如果还要区分按下和普通状态可以加入picture1_mousedown和mouseup过程。
Private Sub Form_Load()
Picture1.Picture = LoadResPicture(102, 0)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Picture = LoadResPicture(102, 0)
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Picture = LoadResPicture(101, 0)
End Sub
'---如果还要区分按下和普通状态可以加入picture1_mousedown和mouseup过程。
展开全部
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Picture1
If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
ReleaseCapture
Picture1.Picture = A.Picture '鼠标移出了
Else
SetCapture .hwnd
Picture1.Picture = B.Picture '鼠标移入
End If
End With
End Sub
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Picture1
If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
ReleaseCapture
Picture1.Picture = A.Picture '鼠标移出了
Else
SetCapture .hwnd
Picture1.Picture = B.Picture '鼠标移入
End If
End With
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询