?
Solved

Read Webbrowser content having hwnd of the window

Posted on 2009-07-09
5
Medium Priority
?
685 Views
Last Modified: 2012-05-07
When I search for the child windows I get:
"
ID: 0, ClassName: Static, Caption:
ID: 0, ClassName: Shell Embedding, Caption:
ID: 0, ClassName: Shell DocObject View, Caption:
ID: 0, ClassName: Internet Explorer_Server, Caption:
"

What I know is that there is a webbrowser withing the application. How can I have access to the application webbrowser content?

I have the hwnd of the application window. How do I go from here for getting the webbrowser content including the url it is taking the info from.

diandr
0
Comment
Question by:diandr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 26

Expert Comment

by:EddieShipman
ID: 24818410
You don't need to use the handle, you can use the ShellWindows to check for the instance of IE you want to
get the doc from by using the code below.
uses ..., ShellAPI, ShDocvw, MSHTML;
 
var
  ShellWindow: IShellWindows;
  WB: IWebbrowser2;
  spDisp: IDispatch;
  IDoc1: IHTMLDocument2;
  k: Integer;
begin
  ShellWindow := CoShellWindows.Create;
  // get the running instance of Internet Explorer
  for k := 0 to ShellWindow.Count do
  begin
    spDisp := ShellWindow.Item(k);
    if spDisp = nil then Continue;
    // QueryInterface determines if an interface can be used with an object
    spDisp.QueryInterface(IWebbrowser2, WB);
    if WB <> nil then
    begin
      WB.Document.QueryInterface(IHTMLDocument2, iDoc1);
      // You now have the HTML document in the iDoc variable...
      if iDoc1.Title = 'Read Webbrowser content having hwnd of the window' then
      begin
        // This page matched the title that I wanted
      end;
    end;
  end;
end;
    

Open in new window

0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 24827256
Well, that won't work for an application that just has an embedded webbrowser. Let me take a closer look.
0
 
LVL 3

Expert Comment

by:smot
ID: 24829141
1) Find the webbrowser handle by enumerating the child windows of that window
2) Retrieve IWebbrowser2 from it (search for GetIEFromHWND)
3) Get IHTMLDocument2 from it to access the wb source
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 2000 total points
ID: 24830472
There is a Delphi implementation here: http://www.bsalsa.com/ie_tools_auto.html
0
 

Author Closing Comment

by:diandr
ID: 31601552
exactly what I wanted
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question