我用 WebBrowse 打开一个网页后,如何将它保存进数据库,而且能够象 Dreamever 那样直接在 那个网页上 进行编辑,比如多加一行文字 等等??
请问 应该如何实现?

解决方案 »

  1.   

    1.
    保存源代码么?
      function GetSource(Document:IHTMLDocument2):String;  
      var i:Integer;pElement:IHTMLElement;
      begin
        Result:='';
        for i:=0 to Document.all.length  -1 do
        begin
          Document.all.item(i,i).QueryInterface(IID_IHTMLElement,pElement);
          if CompareText(pElement.tagName,'HTML') =0 then
          begin
            Result:=pElement.outerHTML;
            exit;
          end;
        end;
      end;2.
    直接编辑
    (WebBrowser1.Document as IHTMLDocument2).exexCommand('EditMode',false,EmptyParam);
      

  2.   

    呵,Eastunfail,把你的函数改了一下...function GetSource(Document:IUnknown):String;
    var
      i:Integer;pElement:IHTMLElement;
      doc:IHTMLDocument3;
    begin
      doc:=Document as IHTMLDocument3;
      Result:=doc.documentElement.outerHTML;end;
      

  3.   

    呵呵,以前还不知道有IHTMLDocument3这个接口,又学到了一点东西了
      

  4.   

    Eastunfailt徒弟,下次有空给你聊DHML模型 与MS HTML DOM模型区别与联系.
      

  5.   

    1 创建一个内存流CreateStreamOnHGlobal
    2 查询HTMLDocument对象的IPersistStream
    3 IPersistStream::Save
    4 用GetHGlobalFromStream获得内存流的句柄
    5 用GlobalLock和GlobalUnlock访问HTML数据