首頁  >  文章  >  ppt怎麼做拖曳互動

ppt怎麼做拖曳互動

尚
原創
2020-01-15 09:23:0023824瀏覽

ppt怎麼做拖曳互動

PPT中實作圖片的拖曳功能的方法:

#一、普通視圖模式

##在普通檢視模式(不是全螢幕模式)下,即在編輯狀態下,自然能實現圖片的拖曳功能。

優點:簡單易行。

缺點:1.視窗較小,視覺化不好;2.自訂動畫效果無法實現。

二、巨集

建議將巨集的安全等級設為低。

1、新建一個ppt空白文件。

2、點選選單:“工具——巨集——巨集”,出現對話方塊。

3、對話方塊中「巨集名」隨意寫個,例如:move,再點「建立」,就進入程式碼模式。

4、刪除所有的程式碼,把下面的程式碼全拷貝進去。

Option Explicit
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare Function MonitorFromPoint Lib "user32.dll" (ByVal x As Long, ByVal y As Long, ByVal dwFlags As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_SCREENX = 0
Private Const SM_SCREENY = 1
Private Const sigProc = "Drag & Drop"
Public Const VK_SHIFT = &H10
Public Const VK_CTRL = &H11
Public Const VK_ALT = &H12
Private Type PointAPI
    x As Long
    y As Long
End Type
Public Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Public mPoint As PointAPI, dPoint As PointAPI
Public ActiveShape As Shape
Dim dragMode As Boolean
Dim dx As Double, dy As Double
Sub DragandDrop(sh As Shape)
dragMode = Not dragMode
If dragMode Then Drag sh
End Sub
Private Sub Drag(sh As Shape)
Dim i As Integer, sx As Integer, sy As Integer
Dim mWnd As Long, WR As RECT
dx = GetSystemMetrics(SM_SCREENX): dPoint.x = dx
dy = GetSystemMetrics(SM_SCREENY): dPoint.y = dy
GetCursorPos mPoint
With ActivePresentation.SlideShowWindow
    mWnd = WindowFromPoint(mPoint.x, mPoint.y)
    GetWindowRect mWnd, WR
    sx = WR.Left
    sy = WR.Top
    dx = (WR.Right - WR.Left) / ActivePresentation.PageSetup.SlideWidth
    dy = (WR.Bottom - WR.Top) / ActivePresentation.PageSetup.SlideHeight
End With
If dx > dy Then
    sx = sx + (dx - dy) * ActivePresentation.PageSetup.SlideWidth / 2
    dx = dy
End If
If dy > dx Then
    sy = sy + (dy - dx) * ActivePresentation.PageSetup.SlideHeight / 2
    dy = dx
End If
While dragMode
    GetCursorPos mPoint
    sh.Left = (mPoint.x - sx) / dx - sh.Width / 2
    sh.Top = (mPoint.y - sy) / dy - sh.Height / 2
    DoEvents
    i = i + 1: If i > 2000 Then dragMode = False: Exit Sub
Wend
End Sub

5、點選儲存後,關閉程式碼模式,回到ppt設計頁面。在你需要拖曳的圖片上點右鍵,選擇「動作設定-點選滑鼠-執行巨集-確定」。

6、放映投影片,看看效果吧。

優點:可視性強。

缺點:對於PPT新手來說不易操作。

以上是ppt怎麼做拖曳互動的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn