資源描述:
《兩種方式實現(xiàn):PPT中實現(xiàn)圖片的拖動功能.doc》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、【PPT中也能實現(xiàn)圖片的拖動功能】本文檔內(nèi)包括兩種方法來實現(xiàn)現(xiàn)對PPT中如何實現(xiàn):當(dāng)播放PPT時,能夠隨意拖動圖片到指定位置(補充:通過插入制作好的FLASH也可以實現(xiàn)這樣的效果,后續(xù)有時間了會接著發(fā)布的,敬請期待)。、一、通過宏實現(xiàn)PPT中圖片的拖動功能此處建議將宏的安全級別設(shè)置為低。1.打開你要設(shè)置圖片拖動功能的PPT。2.點擊菜單:“工具——宏——宏”,出現(xiàn)對話窗口。3.填寫對話窗口中的“宏名”,宏名可以隨意命名,比如:wantmove,再點“創(chuàng)建”,就進入代碼模式。4.刪去所看到的所有的代碼,然后把下面的
2、代碼全拷貝進去。OptionExplicitDeclareFunctionGetKeyStateLib"user32"(ByValnVirtKeyAsLong)AsIntegerPrivateDeclareFunctionWindowFromPointLib"user32"(ByValxPointAsLong,ByValyPointAsLong)AsLongPrivateDeclareFunctionGetWindowRectLib"user32"(ByValhwndAsLong,lpRectAsRECT)AsL
3、ongPrivateDeclareFunctionGetCursorPosLib"user32"(lpPointAsPointAPI)AsLongPrivateDeclareFunctionSetCursorPosLib"user32"(ByValxAsLong,ByValyAsLong)AsLongPublicDeclareFunctionMonitorFromPointLib"user32.dll"(ByValxAsLong,ByValyAsLong,ByValdwFlagsAsLong)AsLongPriv
4、ateDeclareFunctionGetSystemMetricsLib"user32"(ByValnIndexAsLong)AsLongPrivateConstSM_SCREENX=0PrivateConstSM_SCREENY=1PrivateConstsigProc="Drag&Drop"PublicConstVK_SHIFT=&H10PublicConstVK_CTRL=&H11PublicConstVK_ALT=&H12PrivateTypePointAPIxAsLongyAsLongEndTypeP
5、ublicTypeRECTLeftAsLongTopAsLongRightAsLongBottomAsLongEndTypePublicmPointAsPointAPI,dPointAsPointAPIPublicActiveShapeAsShapeDimdragModeAsBooleanDimdxAsDouble,dyAsDoubleSubDragandDrop(shAsShape)dragMode=NotdragModeIfdragModeThenDragsh?EndSubPrivateSubDrag(shA
6、sShape)DimiAsInteger,sxAsInteger,syAsIntegerDimmWndAsLong,WRAsRECTdx=GetSystemMetrics(SM_SCREENX):dPoint.x=dxdy=GetSystemMetrics(SM_SCREENY):dPoint.y=dyGetCursorPosmPointWithActivePresentation.SlideShowWindowmWnd=WindowFromPoint(mPoint.x,mPoint.y)GetWindowRec
7、tmWnd,WRsx=WR.Leftsy=WR.Topdx=(WR.Right-WR.Left)/ActivePresentation.PageSetup.SlideWidthdy=(WR.Bottom-WR.Top)/ActivePresentation.PageSetup.SlideHeightEndWithIfdx>dyThensx=sx+(dx-dy)*ActivePresentation.PageSetup.SlideWidth/2dx=dyEndIfIfdy>dxThensy=sy+(dy-dx)*A
8、ctivePresentation.PageSetup.SlideHeight/2dy=dxEndIfWhiledragModeGetCursorPosmPointsh.Left=(mPoint.x-sx)/dx-sh.Width/2sh.Top=(mPoint.y-sy)/dy-sh.Height/2DoEventsi=i+1:Ifi>2000ThendragMode=