拖放文件--从应用程序往外拖放文件 ( 积分: 100 )

  • 主题发起人 主题发起人 swlove
  • 开始时间 开始时间
S

swlove

Unregistered / Unconfirmed
GUEST, unregistred user!
环境:一个窗体,一个Image控件,其中Image里加载了一张知道具体路径的图片<br><br>请问,如何编程实现把Image里的那张图片拖放到电脑的任意位置&nbsp;??<br><br>谢谢...
 
关注。<br>假如在Winxp里启动一个Vmware虚拟机,里面也是Winxp的话,可以通过拖拽在虚拟机和宿主机之间进行文件交换,应该就是利用了楼上说的方法。
 
拖放,在&nbsp;Windows&nbsp;系统中,本质上就是剪贴板的拷贝。术语是&nbsp;OLE&nbsp;。<br><br>要拖放到&nbsp;Windows&nbsp;管理的任何区域,需要注册一系列&nbsp;Windows&nbsp;定义好的东西,除了数据格<br>式可以自己定义外(自己定义就要自己解析),其他的都是&nbsp;Windows&nbsp;要求知道的东西。如<br>果连数据格式都定义成&nbsp;Windows&nbsp;知道的格式,那么你就可以做到你题目中的要求了。<br><br>由于定义的东西太多,而且都是&nbsp;OLE&nbsp;年代的古董,我需要化很多时间才能理出来,所以在<br>此只好说声抱歉了。自己查资料吧。
 
怡.梦老兄发过一相关帖子<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=2471437<br><br>可我还是搞不掂...<br>是需拖放一已知具体路径的BMP图片....
 
拖进来就容易处理,拖出来就难(小雨哥说啦);
 
在窗口初始化中<br>//设置需要处理文件WM_DROPFILES拖放消息<br>&nbsp;&nbsp;DragAcceptFiles(ListBox1.Handle,&nbsp;TRUE);<br>&nbsp;&nbsp;//设置AppMessage过程来捕获所有消息<br>&nbsp;&nbsp;Application.OnMessage&nbsp;:=&nbsp;AppMessage;<br><br>procedure&nbsp;TForm1.AppMessage(var&nbsp;Msg:&nbsp;TMsg;&nbsp;var&nbsp;Handled:&nbsp;Boolean);<br>var<br>nFiles,&nbsp;UpI:&nbsp;Integer;<br>UpFilename:&nbsp;string;<br>begin<br><br>&nbsp;&nbsp;if&nbsp;(Msg.message&nbsp;=&nbsp;WM_DROPFILES)&nbsp;and&nbsp;(msg.hwnd&nbsp;=&nbsp;ListBox1.Handle)&nbsp;then<br>&nbsp;&nbsp;begin<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nFiles&nbsp;:=&nbsp;DragQueryFile&nbsp;(Msg.wParam,&nbsp;$FFFFFFFF,&nbsp;nil,&nbsp;0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;UpI&nbsp;:=&nbsp;0&nbsp;to&nbsp;nFiles&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetLength&nbsp;(UPFilename,&nbsp;80);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DragQueryFile&nbsp;(Msg.wParam,&nbsp;UpI,&nbsp;PChar&nbsp;(UpFilename),&nbsp;80);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UPFilename&nbsp;:=&nbsp;PChar&nbsp;(UpFilename);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;showmessage(upfilename);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;finally<br><br>&nbsp;&nbsp;&nbsp;&nbsp;DragFinish&nbsp;(Msg.wParam);<br>&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;&nbsp;Handled&nbsp;:=&nbsp;True;<br>end;<br>end;
 
错了错了不好意思&nbsp;看错了<br>是拖出来&nbsp;晕啊&nbsp;我再想想
 
在CSDN里有一例子<br>http://community.csdn.net/Expert/topic/5328/5328765.xml?temp=.6787683<br>可惜我运行出错<br>哪位牛人行的话帮我看看,弄个完整点的代码出来...
 
既然已知道了图片路径了,我有个建议:<br>在拖放时捕获消息,<br>引用shellapi单元&nbsp;SHFILEOPSTRUCT功能<br>执行copy(srcFileName,DesFilePath),<br>也能达到你所想的效果;<br>因为image里的图片是来自硬盘吗,你就当是从硬盘一处往另一处copy就行了
 
蹭分<br><br>unit&nbsp;Unit1;<br><br>interface<br><br>uses<br>&nbsp;&nbsp;Windows,&nbsp;Messages,&nbsp;SysUtils,&nbsp;Variants,&nbsp;Classes,&nbsp;Graphics,&nbsp;Controls,&nbsp;Forms,<br>&nbsp;&nbsp;Dialogs,&nbsp;StdCtrls,&nbsp;FileCtrl,&nbsp;ComObj,&nbsp;ActiveX,&nbsp;ShlObj;<br><br>type<br>&nbsp;&nbsp;TForm1&nbsp;=&nbsp;class(TForm)<br>&nbsp;&nbsp;&nbsp;&nbsp;FileListBox1:&nbsp;TFileListBox;<br>&nbsp;&nbsp;&nbsp;&nbsp;DirectoryListBox1:&nbsp;TDirectoryListBox;<br>&nbsp;&nbsp;&nbsp;&nbsp;DriveComboBox1:&nbsp;TDriveComboBox;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;FileListBox1MouseDown(Sender:&nbsp;TObject;&nbsp;Button:&nbsp;TMouseButton;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Shift:&nbsp;TShiftState;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Private&nbsp;declarations&nbsp;}<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Public&nbsp;declarations&nbsp;}<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;TDrop&nbsp;=&nbsp;class(TInterfacedObject,IDropSource,IDataObject,IEnumFormatEtc)<br>&nbsp;&nbsp;&nbsp;FIndex:&nbsp;Word ;<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;procedure&nbsp;free;<br>&nbsp;&nbsp;&nbsp;//IDropSource<br>&nbsp;&nbsp;&nbsp;function&nbsp;QueryContinueDrag(fEscapePressed:&nbsp;BOOL;&nbsp;grfKeyState:&nbsp;Longint):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;GiveFeedback(dwEffect:&nbsp;Longint):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;//IEnumFormatEtc<br>&nbsp;&nbsp;&nbsp;function&nbsp;AddFormat(Enum:&nbsp;TFormatEtc):&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;function&nbsp;Next(celt:&nbsp;Longint;&nbsp;out&nbsp;elt;&nbsp;pceltFetched:&nbsp;PLongint):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;Skip(celt:&nbsp;Longint):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;Reset:&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;Clone(out&nbsp;Enum:&nbsp;IEnumFormatEtc):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;//IDataObject<br>&nbsp;&nbsp;&nbsp;function&nbsp;GetData(const&nbsp;formatetcIn:&nbsp;TFormatEtc;&nbsp;out&nbsp;medium:&nbsp;TStgMedium):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;GetDataHere(const&nbsp;formatetc:&nbsp;TFormatEtc;&nbsp;out&nbsp;medium:&nbsp;TStgMedium):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;QueryGetData(const&nbsp;formatetc:&nbsp;TFormatEtc):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;GetCanonicalFormatEtc(const&nbsp;formatetc:&nbsp;TFormatEtc;&nbsp;out&nbsp;formatetcOut:&nbsp;TFormatEtc):&nbsp;HResult;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;SetData(const&nbsp;formatetc:&nbsp;TFormatEtc;&nbsp;var&nbsp;medium:&nbsp;TStgMedium;&nbsp;fRelease:&nbsp;BOOL):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;EnumFormatEtc(dwDirection:&nbsp;Longint;&nbsp;out&nbsp;enumFormatEtc:&nbsp;IEnumFormatEtc):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;DAdvise(const&nbsp;formatetc:&nbsp;TFormatEtc;&nbsp;advf:&nbsp;Longint;&nbsp;const&nbsp;advSink:&nbsp;IAdviseSink;&nbsp;out&nbsp;dwConnection:&nbsp;Longint):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;DUnadvise(dwConnection:&nbsp;Longint):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;&nbsp;function&nbsp;EnumDAdvise(out&nbsp;enumAdvise:&nbsp;IEnumStatData):&nbsp;HResult;&nbsp;stdcall;<br>&nbsp;&nbsp;end;<br>var<br>&nbsp;&nbsp;Form1:&nbsp;TForm1;<br><br>implementation<br><br>{$R&nbsp;*.dfm}<br>//IDropSource<br>function&nbsp;TDrop.QueryContinueDrag(fEscapePressed:&nbsp;BOOL;&nbsp;grfKeyState:&nbsp;Longint):&nbsp;HResult;&nbsp;stdcall;<br>begin<br>&nbsp;&nbsp;if&nbsp;fEscapePressed&nbsp;or&nbsp;(grfKeyState&nbsp;and&nbsp;MK_RBUTTON&nbsp;=&nbsp;MK_RBUTTON)&nbsp;then&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;DRAGDROP_S_CANCEL;<br>&nbsp;&nbsp;end&nbsp;else&nbsp;if&nbsp;grfKeyState&nbsp;and&nbsp;MK_LBUTTON&nbsp;=&nbsp;0&nbsp;then&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;DRAGDROP_S_DROP;<br>&nbsp;&nbsp;end&nbsp;else&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;S_OK;<br>&nbsp;&nbsp;end<br>end;<br><br>function&nbsp;TDrop.GiveFeedback(dwEffect:&nbsp;Longint):&nbsp;HResult;&nbsp;stdcall;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;DRAGDROP_S_USEDEFAULTCURSORS;<br>end;<br><br>//IEnumFormatEtc<br>function&nbsp;TDrop.AddFormat(Enum:&nbsp;TFormatEtc):&nbsp;Integer;<br>begin<br>&nbsp;Result&nbsp;:=&nbsp;-1;<br>end;<br><br>function&nbsp;TDrop.Next(celt:&nbsp;Longint;&nbsp;out&nbsp;elt;&nbsp;pceltFetched:&nbsp;PLongint):&nbsp;HResult;&nbsp;stdcall;<br>begin<br>&nbsp;Result&nbsp;:=&nbsp;S_FALSE;<br>&nbsp;if&nbsp;celt=0&nbsp;then&nbsp;Reset;<br>&nbsp;if&nbsp;FIndex&gt;0&nbsp;then&nbsp;exit;<br>&nbsp;with&nbsp;TFormatEtc(elt)&nbsp;do&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;cfFormat&nbsp;:=&nbsp;CF_HDROP;<br>&nbsp;&nbsp;&nbsp;&nbsp;tymed&nbsp;&nbsp;&nbsp;&nbsp;:=&nbsp;TYMED_HGLOBAL;<br>&nbsp;&nbsp;&nbsp;&nbsp;dwAspect&nbsp;:=&nbsp;DVASPECT_CONTENT;<br>&nbsp;&nbsp;&nbsp;&nbsp;lIndex&nbsp;&nbsp;&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;ptd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:=&nbsp;nil;<br>&nbsp;end;<br>&nbsp;if&nbsp;Assigned(pceltFetched)&nbsp;then&nbsp;pceltFetched^:=FIndex;<br><br>&nbsp;if&nbsp;celt&gt;0&nbsp;then&nbsp;Inc(FIndex,celt)&nbsp;else&nbsp;inc(FIndex);<br>&nbsp;Result&nbsp;:=&nbsp;S_OK;<br>end;<br><br>function&nbsp;TDrop.Skip(celt:&nbsp;Longint):&nbsp;HResult;&nbsp;stdcall;<br>begin&nbsp;Result&nbsp;:=&nbsp;S_FALSE&nbsp;&nbsp;end;<br><br>function&nbsp;TDrop.Reset:&nbsp;HResult;&nbsp;stdcall;<br>begin<br>&nbsp;FIndex:=0;<br>&nbsp;Result&nbsp;:=&nbsp;S_OK;<br>end;<br><br>function&nbsp;TDrop.Clone(out&nbsp;Enum:&nbsp;IEnumFormatEtc):&nbsp;HResult;&nbsp;stdcall;<br>begin&nbsp;&nbsp;Result&nbsp;:=&nbsp;E_NOTIMPL;&nbsp;end;&nbsp;//不支持的接口<br><br>//IDataObject<br>function&nbsp;TDrop.GetData(const&nbsp;formatetcIn:&nbsp;TFormatEtc;&nbsp;out&nbsp;medium:&nbsp;TStgMedium):&nbsp;HResult;&nbsp;stdcall;<br>var<br>BufferText&nbsp;:&nbsp;String;<br>pGlobal&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;Pointer;<br>i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;Integer;<br>begin<br>&nbsp;Result&nbsp;:=&nbsp;DV_E_FORMATETC;&nbsp;//不支持的格式<br>&nbsp;if&nbsp;not&nbsp;(Self.QueryGetData(formatetcIn)=S_OK)&nbsp;then&nbsp;exit;<br>&nbsp;&nbsp;&nbsp;FillChar(Medium,Sizeof(TStgMedium),0);<br>&nbsp;&nbsp;&nbsp;Medium.tymed:=formatetcIn.tymed;<br><br>&nbsp;&nbsp;&nbsp;BufferText:=Form1.FileListBox1.Directory+'/';<br>&nbsp;&nbsp;&nbsp;for&nbsp;i:=0&nbsp;to&nbsp;Form1.FileListBox1.Count&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Form1.FileListBox1.Selected&nbsp;then&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BufferText:=BufferText+Form1.FileListBox1.Items+#0+#0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;//需要拖拽多个文件的格式如下<br>&nbsp;&nbsp;&nbsp;//'c:/temp/aa.txt'+#0+#0+'c:/temp/aa.txt'+#0+#0;+'c:/temp/aa.txt'+#0+#0;<br>&nbsp;&nbsp;&nbsp;Medium.hGlobal&nbsp;:=&nbsp;GlobalAlloc(GMEM_ZEROINIT&nbsp;or&nbsp;GMEM_MOVEABLE&nbsp;or&nbsp;&nbsp;GMEM_SHARE,&nbsp;Length(BufferText)+1+Sizeof(TDropFiles));<br>&nbsp;&nbsp;&nbsp;pGlobal&nbsp;:=&nbsp;GlobalLock(Medium.hGlobal);<br>&nbsp;&nbsp;&nbsp;PDropFiles(pGlobal)^.pFiles:=Sizeof(TDropFiles);<br>&nbsp;&nbsp;&nbsp;PDropFiles(pGlobal)^.pt:=Point(0,0);<br>&nbsp;&nbsp;&nbsp;PDropFiles(pGlobal)^.fNC:=False;<br>&nbsp;&nbsp;&nbsp;PDropFiles(pGlobal)^.fWide:=False;<br>&nbsp;&nbsp;&nbsp;inc(Longword(pGlobal),Sizeof(TDropFiles));&nbsp;//指针后移<br>&nbsp;&nbsp;&nbsp;CopyMemory(PGlobal,Pchar(BufferText),Length(BufferText)+1);<br>&nbsp;&nbsp;&nbsp;GlobalUnlock(Medium.hGlobal);<br>&nbsp;&nbsp;&nbsp;Medium.unkForRelease&nbsp;:=&nbsp;nil;<br>&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;S_OK;<br>end;<br><br><br>function&nbsp;TDrop.QueryGetData(const&nbsp;formatetc:&nbsp;TFormatEtc):&nbsp;HResult;&nbsp;stdcall;<br>begin<br>&nbsp;Result&nbsp;:=&nbsp;DV_E_FORMATETC;&nbsp;//不支持的格式<br><br>&nbsp;if&nbsp;(formatetc.cfFormat=CF_HDROP)&nbsp;and&nbsp;&nbsp;//表示支持文件拖拽格式<br>&nbsp;&nbsp;&nbsp;&nbsp;(formatetc.tymed=TYMED_HGLOBAL)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;(formatetc.dwAspect=DVASPECT_CONTENT)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;S_OK;<br>end;<br><br>function&nbsp;TDrop.EnumFormatEtc(dwDirection:&nbsp;Longint;&nbsp;out&nbsp;enumFormatEtc:&nbsp;IEnumFormatEtc):&nbsp;HResult;&nbsp;stdcall;<br>begin<br>&nbsp;Result&nbsp;:=&nbsp;S_FALSE;<br>&nbsp;Reset;<br>&nbsp;case&nbsp;dwDirection&nbsp;of<br>&nbsp;&nbsp;&nbsp;DATADIR_GET&nbsp;:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enumFormatEtc:=Self&nbsp;as&nbsp;IEnumFormatEtc;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;S_OK;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;DATADIR_SET&nbsp;:&nbsp;Result&nbsp;:=&nbsp;E_NOTIMPL;<br>&nbsp;end;<br>end;<br><br>function&nbsp;TDrop.SetData(const&nbsp;formatetc:&nbsp;TFormatEtc;&nbsp;var&nbsp;medium:&nbsp;TStgMedium;&nbsp;fRelease:&nbsp;BOOL):&nbsp;HResult;&nbsp;stdcall;<br>begin&nbsp;Result&nbsp;:=&nbsp;E_NOTIMPL;&nbsp;end;&nbsp;//不支持的接口}<br><br>function&nbsp;TDrop.GetCanonicalFormatEtc(const&nbsp;formatetc:&nbsp;TFormatEtc;&nbsp;out&nbsp;formatetcOut:&nbsp;TFormatEtc):&nbsp;HResult;stdcall;<br>begin&nbsp;Result&nbsp;:=&nbsp;E_NOTIMPL;&nbsp;end;&nbsp;//不支持的接口}<br><br>function&nbsp;TDrop.GetDataHere(const&nbsp;formatetc:&nbsp;TFormatEtc;&nbsp;out&nbsp;medium:&nbsp;TStgMedium):&nbsp;HResult;&nbsp;stdcall;<br>begin&nbsp;Result&nbsp;:=&nbsp;E_NOTIMPL;&nbsp;end;&nbsp;//不支持的接口}<br><br>function&nbsp;TDrop.DAdvise(const&nbsp;formatetc:&nbsp;TFormatEtc;&nbsp;advf:&nbsp;Longint;&nbsp;const&nbsp;advSink:&nbsp;IAdviseSink;&nbsp;out&nbsp;dwConnection:&nbsp;Longint):&nbsp;HResult;&nbsp;stdcall;<br>begin&nbsp;Result&nbsp;:=&nbsp;E_NOTIMPL;&nbsp;end;&nbsp;//不支持的接口}<br><br>function&nbsp;TDrop.DUnadvise(dwConnection:&nbsp;Longint):&nbsp;HResult;&nbsp;stdcall;<br>begin&nbsp;Result&nbsp;:=&nbsp;E_NOTIMPL;&nbsp;end;&nbsp;//不支持的接口}<br><br>function&nbsp;TDrop.EnumDAdvise(out&nbsp;enumAdvise:&nbsp;IEnumStatData):&nbsp;HResult;&nbsp;stdcall;<br>begin&nbsp;Result&nbsp;:=&nbsp;E_NOTIMPL;&nbsp;end;&nbsp;//不支持的接口}<br><br>procedure&nbsp;TDrop.free;<br>begin<br>end;<br><br>procedure&nbsp;TForm1.FileListBox1MouseDown(Sender:&nbsp;TObject;<br>&nbsp;&nbsp;Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>var<br>Effect&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;Longint;<br>DataObject:&nbsp;TDrop;<br>begin<br>if&nbsp;not&nbsp;(Button=mbLeft)&nbsp;then&nbsp;exit;<br>DataObject:=TDrop.Create;<br>Effect&nbsp;:=&nbsp;DROPEFFECT_NONE;<br>OleCheck(DoDragDrop(DataObject&nbsp;as&nbsp;IDataObject,&nbsp;DataObject&nbsp;as&nbsp;IDropSource,&nbsp;DROPEFFECT_COPY,&nbsp;Effect));<br>DataObject.Free;<br>end;<br><br>initialization<br>&nbsp;&nbsp;OleInitialize(nil);<br>finalization<br>&nbsp;&nbsp;OleUninitialize;<br><br>end.
 
谢谢<br>但代码编译没错,可没效果
 
多人接受答案了。
 
后退
顶部