怎样把网页上的超级链接拖到程序中(200分)

  • 主题发起人 中原问鼎
  • 开始时间

中原问鼎

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样把网页上的超级链接拖到程序中??????<br><br>我在编写一个资料整理软件,其中的一功能是把网页上的链接拖到memo中,并把相关链接的内容转化成文本文件存在数据库中(就想吸血鬼拖动url那样)<br>希望大侠提供源码,我是----菜鸟<br>&nbsp; &nbsp;如能解决送270分<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;270分!!!!!!!!!!!<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;270分!!!!!!!!!!!
 
帮帮这个可怜的孩子吧,!!!!!!!!!!!!!!!!!
 
去down一个drag and drop components,<br>肯定让你口水流一地
 
drag and drop components<br>delphi.yesite.com有,我没用过……
 
摘自一本杂志:<br><br>呵呵,这个问题我刚刚遇到过(我写的FreeIP就支持拖放URL)。就是让自己的程序<br>可以接受OLE拖放。这需要申明一个COM对象,并支持IDropTarget接口。<br>下面DragDrop.pas不是我写的:<br>unit DragDrop;<br><br>interface<br><br>uses<br>&nbsp; Windows, ActiveX, ComObj,Dialogs,Sysutils;<br><br>type<br>&nbsp; TDropEvent = procedure(Sender:TObject;Msg:pchar)of object;<br>&nbsp; TTMyDrop = class(TComObject, IDropTarget)<br>&nbsp; private<br>&nbsp; &nbsp; FOnDroped: TDropEvent;<br>&nbsp; &nbsp; procedure SetOnDroped(const Value: TDropEvent);<br>&nbsp; protected<br>&nbsp; &nbsp; {Declare IDropTarget methods here}<br>&nbsp; &nbsp; function DragEnter(const dataObj: IDataObject; grfKeyState: Longint;<br>&nbsp; &nbsp; &nbsp; pt: TPoint; var dwEffect: Longint): HResult; stdcall;<br>&nbsp; &nbsp; function DragOver(grfKeyState: Longint; pt: TPoint;<br>&nbsp; &nbsp; &nbsp; var dwEffect: Longint): HResult; stdcall;<br>&nbsp; &nbsp; function DragLeave: HResult; stdcall;<br>&nbsp; &nbsp; function Drop(const dataObj: IDataObject; grfKeyState: Longint; pt: TPoint;<br>&nbsp; &nbsp; &nbsp; var dwEffect: Longint): HResult; stdcall;<br>&nbsp; public<br>&nbsp; &nbsp; property OnDroped:TDropEvent read FOnDroped write SetOnDroped;<br>&nbsp; end;<br><br>const<br>&nbsp; Class_TMyDrop: TGUID = '{846C94F8-7649-11D2-9836-0000E82EA1B1}';<br><br>implementation<br><br>uses ComServ,unit1;<br><br>{ TTMyDrop }<br><br>function TTMyDrop.DragEnter(const dataObj: IDataObject;<br>&nbsp; grfKeyState: Integer; pt: TPoint; var dwEffect: Integer): HResult;<br>var<br>&nbsp; enumFormatEtc: IEnumFormatEtc;<br>&nbsp; f:TFORMATETC;<br>&nbsp; count:Integer;<br>&nbsp; Found:boolean;<br>begin<br>&nbsp; dataObj.EnumFormatEtc(DATADIR_GET,enumFormatEtc);<br>&nbsp; Found:=false;<br>&nbsp; while (enumFormatEtc.Next(1,f,@count)=S_OK)and (count&gt;0) do<br>&nbsp; begin<br>&nbsp; &nbsp; if (f.cfFormat=CF_TEXT) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Found:=true;<br>&nbsp; &nbsp; &nbsp; Break;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; if Found then<br>&nbsp; &nbsp; Result:=S_OK<br>&nbsp; else<br>&nbsp; begin<br>&nbsp; &nbsp; result:=E_INVALIDARG;<br>&nbsp; &nbsp; dwEffect:=DROPEFFECT_NONE;<br>&nbsp; end;<br>end;<br><br>function TTMyDrop.DragLeave: HResult;<br>begin<br>&nbsp; &nbsp;result := S_OK;<br>end;<br><br>function TTMyDrop.DragOver(grfKeyState: Integer; pt: TPoint;<br>&nbsp; var dwEffect: Integer): HResult;<br>begin<br>&nbsp; &nbsp;result := S_OK;<br>end;<br><br>function TTMyDrop.Drop(const dataObj: IDataObject; grfKeyState: Integer;<br>&nbsp; pt: TPoint; var dwEffect: Integer): HResult;<br>var<br>&nbsp; enumFormatEtc: IEnumFormatEtc;<br>&nbsp; f:TFORMATETC;<br>&nbsp; count:Integer;<br>&nbsp; Found:boolean;<br>&nbsp; medium: TStgMedium;<br>begin<br>&nbsp; dataObj.EnumFormatEtc(DATADIR_GET,enumFormatEtc);<br>&nbsp; Found:=false;<br>&nbsp; while (enumFormatEtc.Next(1,f,@count)=S_OK)and (count&gt;0) do<br>&nbsp; begin<br>&nbsp; &nbsp; if (f.cfFormat=CF_TEXT) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Found:=true;<br>&nbsp; &nbsp; &nbsp; Break;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; if not Found then<br>&nbsp; begin<br>&nbsp; &nbsp; result:=E_INVALIDARG;<br>&nbsp; &nbsp; dwEffect:=DROPEFFECT_NONE;<br>&nbsp; &nbsp; Exit;<br>&nbsp; end;<br>&nbsp; dataObj.GetData(f,medium);<br>&nbsp; if medium.tymed =1 then<br>&nbsp; begin<br>&nbsp; &nbsp; if Assigned(fOnDroped) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; fOnDroped(Self,PChar(GlobalLock(medium.hglobal)));<br>&nbsp; &nbsp; &nbsp; GlobalUnLock(medium.hglobal);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; result := S_OK;<br>&nbsp; end;<br><br>end;<br><br>procedure TTMyDrop.SetOnDroped(const Value: TDropEvent);<br>begin<br>&nbsp; FOnDroped := Value;<br>end;<br><br>initialization<br>&nbsp; TComObjectFactory.Create(ComServer, TTMyDrop, Class_TMyDrop,<br>&nbsp; &nbsp; 'TMyDrop', '', ciMultiInstance{, tmApartment});<br>end.<br><br>在自己的程序中,在FormCreate的时候,加入:<br><br>&nbsp; OleInitialize(NIL);<br>&nbsp; dd := TTMyDrop.Create;<br>&nbsp; dd.OnDroped:=DoDroped;<br>&nbsp; res1 := CoLockObjectExternal(dd, true, false);<br>&nbsp; res := RegisterDragDrop(Handle, IDropTarget(dd));<br><br>其中,DoDroped在拖放发生时被调用:<br>procedure TForm1.DoDroped(Sender: TObject; Msg: Pchar);<br>begin<br>&nbsp; ...//此处最好不要有太耗时的工作,因为被拖出的程序(比如说是浏览器)<br>&nbsp; &nbsp; &nbsp;//要等待此事件结束<br>end;<br><br>在FormDestroy时:<br>&nbsp; RevokeDragDrop(Handle);<br>&nbsp; OleUninitialize;<br><br>一定要用COM对象吗?<br>用OLE2 接口就行了吧!<br>TTMyDrop = class(TInterfacedObject, IDropTarget)<br>这样用的资源更少,也不用包含与com有关的unit了,只用<br>包含activex就行了。<br>也不用产生TComObjectFactory。<br><br>希望对你有帮助!<br>
 
浪刀:你的没试过,但问题解决了,谢谢你,100分<br>hubdog,wjiachun:谢谢,控件找到了,谢谢,各50分
 
顶部