Home > Common Problem > body text

How to make drag interaction in ppt

Release: 2020-01-15 09:23:00
Original
23781 people have browsed it

How to make drag interaction in ppt

How to implement the dragging function of pictures in PPT:

1. Normal view mode

In normal view mode (not full screen mode), that is, in the editing state, the dragging function of the picture can naturally be realized.

Advantages: Simple and easy.

Disadvantages: 1. The window is small and the visibility is not good; 2. Custom animation effects cannot be realized.

2. Macros

It is recommended to set the security level of macros to low.

1. Create a new blank ppt document.

2. Click the menu: "Tools - Macro - Macro" and a dialog box will appear.

3. Write a random name for the "macro name" in the dialog box, such as: move, and then click "Create" to enter the code mode.

4. Delete all the code and copy the following code into it.

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
Copy after login

5. After clicking save, close the code mode and return to the ppt design page. Right-click on the picture you want to drag and select "Action Settings - Click Mouse - Run Macro - OK".

6. Show the slideshow and see the effect.

Advantages: Strong visibility.

Disadvantages: It is not easy to operate for PPT novices.

The above is the detailed content of How to make drag interaction in ppt. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!