我用了如下代码,可不能实现。
类部分:
  TWebB = class(Twebbrowser)
  private
    { Private declarations }  protected
    { Protected declarations }
  public
    function DragEnter(const dataObj: IDataObject; grfKeyState: Longint;pt: TPoint; var dwEffect: Longint): HResult; stdcall;
    function DragOver(grfKeyState: Longint; pt: TPoint;var dwEffect: Longint): HResult; stdcall;
    function DragLeave: HResult; stdcall;
    function Drop(const dataObj: IDataObject; grfKeyState: Longint; pt: TPoint;var dwEffect: Longint): HResult; stdcall;
程序部分
var web1:tweb;
form1.FormCreate
begin
  web:=tweb.create(nil);
  OleInitialize(NIL);
  RegisterDragDrop(web.Handle, IDropTarget(web));
end;

解决方案 »

  1.   

    我也帮你顶啊呵呵。有个API可以现实 。不过我忘了
      

  2.   

    http://blog.csdn.net/jiangsheng/archive/2004/03/20/3800.aspx
    虽然是监视复制粘贴的,但是理论上对拖放也应该有效
      

  3.   

    // uses ActiveX;
    // Put this Code at the end of your unit:initialization
      OleInitialize(nil);finalization
      OleUninitialize; 
      

  4.   

    jiangsheng 的例子比较接近,不过是VC的,delphi如何实现能否告知。我看了MYIE的拖放部分的代码,基本上就是实现了IDropTarget的DragEnter等功能,由于我对VC并不熟悉,所以看了半天仍然没有闹明白。
      

  5.   

    不但是VC的而且使用了MFC
    或许你应该找找用Delphi开发,使用IE控件的代码
      

  6.   

    看看这个对你是不是有帮助
    D:\Program Files\Borland\Delphi7\Demos\Ipcdemos
      

  7.   

    我自己通过编写一个 TOleServer 继承类 THTMLDocument 的方式来捕捉所以的事件,根据这些事件,可以很方便完成拖放等自定义操作。由于时间问题,暂时只完成部分事件的捕捉,其他的类同(很方便加入的,事件的 DispID 请见了 MSHTML.pas),供参考,使用的时候 ConnectTo 到 WebBrowser 的 Document (必须先加载文档)。type
      THTMLDocumentEvent = procedure (Sender: TObject; const pEvtObj:
              IHTMLEventObj) of object;  THTMLDocument = class(TOleServer)
      private
        FIntf: IHTMLDocument2;
        FOnClick: THTMLDocumentEvent;
        FOnMouseMove: THTMLDocumentEvent;
        function GetDefaultInterface: IHTMLDocument2;
      protected
        procedure InitServerData; override;
        procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray); override;
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
        procedure Connect; override;
        procedure ConnectTo(svrIntf: IHTMLDocument2);
        procedure Disconnect; override;
        property DefaultInterface: IHTMLDocument2 read GetDefaultInterface;
      published
        property OnClick: THTMLDocumentEvent read FOnClick write FOnClick;
        property OnMouseMove: THTMLDocumentEvent read FOnMouseMove write
                FOnMouseMove;
      end;{
    ******************************** THTMLDocument *********************************
    }
    constructor THTMLDocument.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
    end;destructor THTMLDocument.Destroy;
    begin
      inherited Destroy;
    end;procedure THTMLDocument.Connect;
    var
      punk: IUnknown;
    begin
      if FIntf = nil then
      begin
        punk := GetServer;
        ConnectEvents(punk);
        FIntf:= punk as IHTMLDocument2;
      end;
    end;procedure THTMLDocument.ConnectTo(svrIntf: IHTMLDocument2);
    begin
      Disconnect;
      FIntf := svrIntf;
      ConnectEvents(FIntf);
    end;procedure THTMLDocument.Disconnect;
    begin
      if FIntf <> nil then
      begin
        DisconnectEvents(FIntf);
        FIntf := nil;
      end;
    end;function THTMLDocument.GetDefaultInterface: IHTMLDocument2;
    begin
      if FIntf = nil then
        Connect;
      Assert(FIntf <> nil, 'DefaultInterface is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation');
      Result := FIntf;
    end;procedure THTMLDocument.InitServerData;
      
      const
        CServerData: TServerData = (
        ClassID:   '{25336920-03F9-11CF-8FD0-00AA00686F13}';
        IntfIID:   '{332C4425-26CB-11D0-B483-00C04FD90119}';
        EventIID:  '{3050F613-98B5-11CF-BB82-00AA00BDCE0B}';
        LicenseKey: nil;
        Version: 500);
      
    begin
      ServerData := @CServerData;
    end;procedure THTMLDocument.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
    var
      pDisp: IDispatch;
      pEventObj: IHTMLEventObj;
    begin
      if DispID = -1 then Exit;
      pDisp := Params[0];
      if pDisp.QueryInterface(IHTMLEventObj, pEventObj) <> 0 then Exit;
      case DispID of
        -1: Exit;  // DISPID_UNKNOWN
        -600: if Assigned(FOnClick) then
                  FOnClick(Self, pEventObj);
        -606: if Assigned(FOnMouseMove) then
                  FOnMouseMove(Self, pEventObj);
      end;
    end;
      

  8.   

    to zhengcg(楚楚):
     可该如何使用THTMLDocument类呢?(如何让THEMLDocument和TWEBBROWSER关联)
      

  9.   

    确实这个类还不算很完整,如事件不全、还有对事件指针的情况判断不全,比较完整的例子见:http://community.csdn.net/Expert/topic/3267/3267026.xml?temp=.3797876。
    这个类在我自己的计算机上调试都正常(一台是 2000,一台是 XP,IE都是 6.0),而且已经在程序里使用了。有个网友说在 IE 5.0 不行,会提示出错,确实我自己没有试过。关于这个类的编写,大家可以定义 TWebBrowser,其中的类:TInternetExplorer,就很类似,我就是参考这个写出来的。使用办法就是(我已经把这个类编译成组件了):WebBrowser1.Navigate('about:blank');
    while WebBrowser1.ReadyState <> READYSTATE_COMPLETE do
      Application.ProcessMessages;
    HTMLDocument1.ConnectTo(ITHMLDocument2(WebBrowser1.Document));
    //注:只要连接一次就可以了,以后就会把所有的事件都关联上了。