|
验证StdPicture对象的存在
Sub x()
Dim P As StdPicture
Set P = LoadPicture(ThisWorkbook.Path & "\a.jpg")
MsgBox P.Width & " " & P.Height
Set P = Nothing
End Sub
简单应用的例子(窗体画上个Image)
Private xX As Long, xY As Long
Private Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
xX = x
xY = Y
End Sub
Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
If Button = 0 Then Exit Sub
Dim dx As Long, dy As Long, ll As Long, tt As Long
With Image1
dy = Y - xY
dx = x - xX
ll = .Left
tt = .Top
.Move ll + dx, tt + dy
End With
End Sub
Private Sub UserForm_Initialize()
Dim P As StdPicture
Set P = LoadPicture(ThisWorkbook.Path & "\a.jpg")
Image1.Height = P.Height * 0.567 / 19.6
Image1.Width = P.Width * 0.567 / 19.6
Image1.Picture = P
Set P = Nothing
End Sub
不解释,有兴趣者去查查smdn |
|