VB按钮如何实现随着鼠标移动而变换颜色?
VB自带的按钮样式不太好看,我自己PS了2张图片做按钮.我希望运行程序的时候是第1张图片,当鼠标移动到这个按钮图片上的时候,第2张图片能够出来,当鼠标离开这个按钮的时候,...
VB自带的按钮样式不太好看,我自己PS了2张图片做按钮.我希望运行程序的时候是第1张图片,当鼠标移动到这个按钮图片上的时候,第2张图片能够出来,当鼠标离开这个按钮的时候,又恢复成原来的图片,因为我是初学者,所以写了下面的代码:Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)Image2.Visible = TrueEnd SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)Image2.Visible = FalseEnd Sub可是这串代码有写弊端,因此我想要当鼠标在这个按钮图片上的时候第2张图片出来,当鼠标不在这个按钮图片上的时候(无论鼠标在哪),显示的都是第1张图片,这个效果要怎么实现啊?
展开
展开全部
Const Img1 As String = "c:\1.jpg"
Const Img2 As String = "c:\2.jpg"
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = LoadPicture(Img2)
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = LoadPicture(Img1)
End Sub
Const Img2 As String = "c:\2.jpg"
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = LoadPicture(Img2)
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = LoadPicture(Img1)
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询