Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 154
  • Last Modified:

Get Document for a specified IE

I wish to get the Document for a specified IE browser.

Something alike MyIE.Document.....
0
ginsonic
Asked:
ginsonic
  • 3
  • 2
1 Solution
 
loop_untilCommented:
To have inner text you might want to use something like:

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
  Frame, Bod: Variant;
begin
  // To get inner text
  Frame := IWebBrowser(pDisp).Document;
  Bod := Frame.Body;
  Memo1.Text := Bod.InnerText;
end;


Does it helps?
Have a nice day! :-)
0
 
loop_untilCommented:
0
 
ginsonicAuthor Commented:
I wish to get from IE and not WebBrowser.
0
 
ginsonicAuthor Commented:
From

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20531867.html

I try to replace the getHTML with something alike getSnap with next:

var  ViewObject: IViewObject;
 sourceDrawRect: TRect;

...

if WB.Document <> nil then
   try
      WB.Document.QueryInterface(IViewObject, ViewObject);
      if ViewObject <> nil then
      try
         sourceDrawRect := Rect(0, 0, WB.Width, Wb.Height);
         ViewObject.Draw(DVASPECT_CONTENT, 1, nil, nil, Self.Handle,
         image1.Canvas.Handle, @sourceDrawRect, nil, nil, 0);
      finally
         ViewObject._Release;
      end;
      Image1.Canvas.Refresh;
   except
   end;

But can't success :(
0
 
loop_untilCommented:
This is for HTML source:

var
  HTMLDocument: IHTMLDocument2;
  PersistFile: IPersistFile;
begin
  ...
  HTMLDocument := WebBrowser1.Document as IHTMLDocument2;
  PersistFile := HTMLDocument as IPersistFile;
  PersistFile.Save(StringToOleStr('test.htm'), True);

  while HTMLDocument.readyState <> 'complete' do
    Application.ProcessMessages;
     ...
end;


Better?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now