image控件在mouseup事件中变换图片
准备两张图片,image控件里引用的是一张图片,当mouse移动到上面去时,显示是另外一张图片.在mouseup事件中加入改变图片的代码. 请问这个代码是什么
[解决办法]
显示图片的那个用Image不太容易实现, 换成PictureBox:
Option Explicit
Private Declare Function SetCapture Lib "user32 " (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32 " () As Long
Private Sub Form_Load()
Picture1.Picture = Image1.Picture
End Sub
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
.Picture = Image1.Picture
ReleaseCapture
Else
.Picture = Image2.Picture
SetCapture .hwnd
End If
End With
End Sub