位置:首頁(yè) > 軟件操作教程 > 辦公軟件 > PPT > 問題詳情

在PPT中實(shí)現(xiàn)任意拖放圖片效果的方法

提問人:周麗平發(fā)布時(shí)間:2021-09-15

1、插入圖片(這個(gè)不能用插入圖片的方法,而是通過圖片控件(image控件)的方法,如下圖:

image.png

image.png

2、雙擊圖像控件,輸入以下代碼:

Dim X1, Y1 As Integer '用來(lái)記錄位置

Dim Down As Boolean '用來(lái)判斷拖放狀態(tài)

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)

'記算移動(dòng)距離

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)

'改變移動(dòng)狀態(tài)并顯示移動(dòng)后的圖片

Down = False

SlideShowWindows(1).View.First

End Sub

繼續(xù)查找其他問題的答案?

回復(fù)(0)
返回頂部