首页 >常见问题 > 正文

ppt怎么做拖动互动

原创2020-01-15 09:23:000247
phpStudy Linux 面板(小皮面板)

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中文网其它相关文章!

php中文网最新课程二维码
  • 相关标签:ppt 拖动
  • 本文原创发布php中文网,转载请注明出处,感谢您的尊重!
  • 相关文章

    相关视频


    网友评论

    文明上网理性发言,请遵守 新闻评论服务协议

    我要评论
  • 专题推荐

    推荐视频教程
  • PHP数据库编程零基础入门到精通PHP数据库编程零基础入门到精通
  • PHP经典算法面试题PHP经典算法面试题
  • PHP文件基础操作PHP文件基础操作
  • PHP开发免费公益直播课PHP开发免费公益直播课
  • 视频教程分类