[トップ][一覧][最近の更新]

編集履歴:差分

記録開始以来のOLEドラッグ・アンド・ドロップの変更箇所

  • + 追加された行
  • - 削除された行

編集履歴ページに戻る

- hscallbk.dllを使って、IDropTargetを実装してみる。
- 
- [[$$toc]]
- - →[[HSP3・サンプルスクリプト]]に戻る
- 
- ----
- 
- HSP3.0aで動作確認
- 
- IEやワードなどからのD&D(リンクやコピー)を受け取ってみる。~%
- サンプルというより実験的ですが・・・
- 微妙・・・~%
- 
- 
- * スクリプト
- 
- {{{
- ; <<<< HSP 3.0a サンプル >>>>
- ;
- ;  IDropTargetを実装してみる。
- ;
- 
- onexit gosub *exit
- 
- #include "hscallbk.as"
- 
- #define E_NOINTERFACE   $80004002
- #define E_UNEXPECTED    $8000FFFF
- 
- #uselib "KERNEL32.DLL"
- #cfunc global GlobalLock "GlobalLock" int
- #func  global GlobalUnlock "GlobalUnlock" int
- 
- #uselib "OLE32.DLL"
- #cfunc global IsEqualGUID "IsEqualGUID" int,var
- #func  global RegisterDragDrop "RegisterDragDrop" int,int
- #func  global RevokeDragDrop "RevokeDragDrop" int
- #func  global ReleaseStgMedium "ReleaseStgMedium" var
- 
- ;IDataObject Methods in VTable Order
- #usecom  IDataObject "{0000010e-0000-0000-C000-000000000046}"
- #comfunc IDataObject_QueryInterface 0 int,int
- #comfunc IDataObject_AddRef         1
- #comfunc IDataObject_Release        2
- #comfunc IDataObject_GetData        3 var,var
- 
- ;IDropTarget-------------------------------------
- #uselib ""
- #func QueryInterface "" int,int,int
- #func AddRef ""         int        
- #func Release ""        int
- #func DragEnter ""      int,int,int,int,int,int
- #func DragOver ""       int,int,int,int,int
- #func DragLeave ""      int
- #func Drop ""           int,int,int,int,int,int
- 
- setcallbk P1 ,QueryInterface, *OnQueryInterface
- setcallbk P2 ,AddRef,         *OnAddRef
- setcallbk P3 ,Release,        *OnRelease
- setcallbk P4 ,DragEnter,      *ODragEnter
- setcallbk P5 ,DragOver,       *OnDragOver
- setcallbk P6 ,DragLeave,      *OnDragLeave
- setcallbk P7 ,Drop,           *OnDrop
- ;--------------------------------------------
- 
- dim FORMATETC,5
- dim IIDropTarget,4:IIDropTarget=290,0,192,1174405120
- dim IIUnknown,4   :IIUnknown   =  0,0,192,1174405120
- dim STGMEDIUM,3
- dim vtable,7
- 
- ;IDropTarget Methods in VTable Order
- vtable.0 =varptr(P1),varptr(P2),varptr(P3),varptr(P4)
- vtable.4 =varptr(P5),varptr(P6),varptr(P7)
- dvtable= varptr(vtable)
- ppvtable=varptr(dvtable)
- 
- gsel 0,1
- RegisterDragDrop hwnd,ppvtable
- stop
- 
- *OnQueryInterface
- 
-         This=     callbkarg(0)
-         piid=     callbkarg(1)
-         ppvObject=callbkarg(2)
- 
-         ppvObject=0
-         if (IsEqualGUID(piid,IIUnknown))   {ppvObject =This}
-         if (IsEqualGUID(piid,IIDropTarget)){ppvObject =This}
-         if (ppvObject){
-                 hr=callfunc(prm,vtable.1,0);Ref++
-         return 0
-         }
- 
- return E_NOINTERFACE
- 
- *OnAddRef
- 
-         Ref++
- 
- return Ref
- 
- *OnRelease ; 
- 
-        Ref--
- 
-        if Ref<=0{
-                 ppvtable=0
-         return 0
-         }
- 
- return Ref
- 
- *ODragEnter
- 
- /*
- (OLEDropTarget *pThis, IDataObject *pDataObject,
- DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
- */
-         ;This=      callbkarg(0)
-         ;DataObject=callbkarg(1)
-         grfKeyState=callbkarg(2)
-         pt.0=       callbkarg(3)
-         pt.1=       callbkarg(4)
-         pdwEffect=  callbkarg(5)
- 
-         dupptr Effect,pdwEffect,4
-         title ""+ pt.0+"  "+pt.1+" "+ ginfo(0)+" "+ginfo(1)+" "+Effect
-         Effect=1|4
- 
- return  0
- 
- *OnDragOver
- 
-         ;This=      callbkarg(0)
-         grfKeyState=callbkarg(1)
-         pt.0=       callbkarg(2)
-         pt.1=       callbkarg(3)
-         pdwEffect=  callbkarg(4)
- 
-         dupptr Effect,pdwEffect,4
-         title ""+ pt.0+"  "+pt.1+" "+ ginfo(0)+" "+ginfo(1)+" "+Effect
-         Effect=1|4
- 
- return 0
- 
- *OnDragLeave
- 
- return 0
- 
- *OnDrop
- 
-         pdwEffect=callbkarg(5)
- 
-         dupptr Effect,pdwEffect,4
-         FORMATETC=$00000001,0,1,-1,1
- 
-         newcom pDataObject,,-2,callbkarg(1)
-         IDataObject_GetData pDataObject,FORMATETC,STGMEDIUM
-         delcom pDataObject : pDataObject=0
- 
-         if STGMEDIUM.0=0{
-                 Effect=0 : ReleaseStgMedium STGMEDIUM
-         return E_UNEXPECTED
-         }
-         pbuf=GlobalLock(STGMEDIUM.1)
- 
-         sdim buf,520
-         dupptr buf,pbuf,520,2
-         mes buf
- 
-         GlobalUnlock STGMEDIUM.1
-         ReleaseStgMedium STGMEDIUM
-         Effect=1
- 
- return 0
- 
- *exit
- 
-         RevokeDragDrop hwnd
-         ;hr=callfunc(prm,vtable.2,0);動いている
-         ppvtable=0
-         ;dialog "デバッグ用"
- 
- end
- 
- }}}
- * memo
- 
- 2006/04/08 13:28:31 JST~%
- 変更~%
- onexit *exit -> onexit gosub *exit
- 
- 2006/04/28 10:17:30 JST~%
- なんか掲示板で指摘があったので修正しました。(てへ(*^^))~%
- -2なんて・・・
- 動作不安定のため削除しました