位置:首页 > 软件操作教程 > 办公软件 > PPT > 问题详情

在PPT中实现任意拖放图片效果的方法

提问人:周丽平发布时间:2021-09-15

1、插入图片(这个不能用插入图片的方法,而是通过图片控件(image控件)的方法,如下图:

image.png

image.png

2、双击图像控件,输入以下代码:

Dim X1, Y1 As Integer '用来记录位置

Dim Down As Boolean '用来判断拖放状态

Dim X2, Y2 As Integer

Dim Down2 As Boolean

'——————————————————————————

Private Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

'按下并记录位置

If Not Down Then

X1 = X

Y1 = Y

Down = True

End If

End Sub

Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

'记算移动距离

If Down Then

Image1.Left = Image1.Left + X - X1

Image1.Top = Image1.Top + Y - Y1

X1 = X

Y1 = Y

End If

End Sub

Private Sub Image1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

'改变移动状态并显示移动后的图片

Down = False

SlideShowWindows(1).View.First

End Sub

继续查找其他问题的答案?

回复(0)
返回顶部