Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
X1 = X
Y1 = Y
End If
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Image1.Move Image1.Left + X - X1, Image1.Top + Y - Y1
End If
End Sub
这样即可:(假设有P1和P2两个PictureBox,要将P1中的图像缩放后显示到P2)
Declare Function StretchBlt……'声明API函数StretchBlt,具体语句请用API浏览器生成吧。
Dim w As Integer,h As Integer
Me.ScaleMode = vbPixels
w = P1.Width
h = P1.Height
StretchBlt P2.hdc, 0, 0, W*2, h*2, P1.hdc, 0, 0, w, h, vbSrcCopy
以上语句中w*2、h*2的表示宽和高都放大两倍,您也可以改成其他任意数值,大于1表示放大,小于1表示缩小。
(注意:只适用于PictureBox)