Use IWebBrowser in COM component 
Author Message
 Use IWebBrowser in COM component

Hi everybody!

I have a COM compoment (a dll) and within this component Id like to access
a web site, load it and parse its elements (e.g. Id like to be able to
access their tables + contents etc.). I thought MSHTML would be a good
choice and using IHTMLDocument should provide all required functionality. To
get the IHTMLDocument one must call the get_document() method of
IWebBrowser2 - so far my theory.

But why cant I just use a CComPtr<IWebBrowser2>, call CoCreateInstance()
and the use its Navigate2() method to access a web site? How can I use it
in my dll? Or cant I use it at all? Are there any other possibilities?

Regards

Markus



Sun, 22 Feb 2004 19:53:55 GMT  
 Use IWebBrowser in COM component
Hi,

You cannot use IWebBrowser2 interface that way. The preferred usage of
IWebBrowser2 is that you enumerate all running IE instances and get
IWebBrowser2 interface from one of them. In your case, you can use
ShellExecute to run one instance of IE. Below are some code snippet about
this issue.

   SHDocVw::IShellWindowsPtr m_spSHWinds;
  .............
      long nCount = m_spSHWinds->GetCount();
...............
      IDispatchPtr spDisp;
.............
         spDisp = m_spSHWinds->Item(va);
..............
         SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);

For detailed information, please refer to the following KB article.
http://support.microsoft.com/support/kb/articles/q176/7/92.asp

Thanks,
Kelton



Sun, 22 Feb 2004 21:22:48 GMT  
 Use IWebBrowser in COM component
I tried the little bit of functionality that you posted, and I didn't have
any more success than you did in a non-visual COM object.

However, in an ActiveX control, I have a browser that I use. When I made the
control non-visible (ShowWindow(SW_HIDE)), the web browser object worked
just fine. So, if your COM object has a visual component, drop the Web
Browser control onto your resource, and then just hide it and use it.  If
your COM Object does not have a visual component, I'm not sure where to go
from here.

One other possible solution would be to just send a GET to the web browser
requesting the document that you want, stripping the returned text out, and
then loading it into the XML DOM, as long as the HTML is well-formed. I
haven't even tried to experiment with that one, it is just a brain-fart.
(Probably pretty stinky as well).

Good luck,
Dave White
http://www.slb.com


Quote:
> Hi everybody!

> I have a COM compoment (a dll) and within this component Id like to
access
> a web site, load it and parse its elements (e.g. Id like to be able to
> access their tables + contents etc.). I thought MSHTML would be a good
> choice and using IHTMLDocument should provide all required functionality.
To
> get the IHTMLDocument one must call the get_document() method of
> IWebBrowser2 - so far my theory.

> But why cant I just use a CComPtr<IWebBrowser2>, call CoCreateInstance()
> and the use its Navigate2() method to access a web site? How can I use it
> in my dll? Or cant I use it at all? Are there any other possibilities?

> Regards

> Markus



Sun, 22 Feb 2004 22:03:19 GMT  
 Use IWebBrowser in COM component
Hi !

Thanks for your answer - Ill have a look at the article and test it. Using
your suggestion means that during the runtime of my component also an IE
must be running?

Thanks

Markus


Quote:
> Hi,

> You cannot use IWebBrowser2 interface that way. The preferred usage of
> IWebBrowser2 is that you enumerate all running IE instances and get
> IWebBrowser2 interface from one of them. In your case, you can use
> ShellExecute to run one instance of IE. Below are some code snippet about
> this issue.

>    SHDocVw::IShellWindowsPtr m_spSHWinds;
>   .............
>       long nCount = m_spSHWinds->GetCount();
> ...............
>       IDispatchPtr spDisp;
> .............
>          spDisp = m_spSHWinds->Item(va);
> ..............
>          SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);

> For detailed information, please refer to the following KB article.
> http://support.microsoft.com/support/kb/articles/q176/7/92.asp

> Thanks,
> Kelton



Sun, 22 Feb 2004 22:52:18 GMT  
 Use IWebBrowser in COM component
Hi Dave!

Thanks for you reply. Ill try your suggestion - although Im not sure if it
is possible to add hidden windows to a non-visual COM component :-)

Regards

Markus


Quote:
> I tried the little bit of functionality that you posted, and I didn't have
> any more success than you did in a non-visual COM object.

> However, in an ActiveX control, I have a browser that I use. When I made
the
> control non-visible (ShowWindow(SW_HIDE)), the web browser object worked
> just fine. So, if your COM object has a visual component, drop the Web
> Browser control onto your resource, and then just hide it and use it.  If
> your COM Object does not have a visual component, I'm not sure where to go
> from here.

> One other possible solution would be to just send a GET to the web browser
> requesting the document that you want, stripping the returned text out,
and
> then loading it into the XML DOM, as long as the HTML is well-formed. I
> haven't even tried to experiment with that one, it is just a brain-fart.
> (Probably pretty stinky as well).

> Good luck,
> Dave White
> http://www.slb.com



> > Hi everybody!

> > I have a COM compoment (a dll) and within this component Id like to
> access
> > a web site, load it and parse its elements (e.g. Id like to be able to
> > access their tables + contents etc.). I thought MSHTML would be a good
> > choice and using IHTMLDocument should provide all required
functionality.
> To
> > get the IHTMLDocument one must call the get_document() method of
> > IWebBrowser2 - so far my theory.

> > But why cant I just use a CComPtr<IWebBrowser2>, call
CoCreateInstance()
> > and the use its Navigate2() method to access a web site? How can I use
it
> > in my dll? Or cant I use it at all? Are there any other possibilities?

> > Regards

> > Markus



Sun, 22 Feb 2004 22:54:21 GMT  
 Use IWebBrowser in COM component
For a UI-less HTML parser, see WalkAll sample. You don't need WebBrowser for
this, raw MSHTML is enough.
--
With best wishes,
    Igor Tandetnik


Quote:
> Hi everybody!

> I have a COM compoment (a dll) and within this component Id like to
access
> a web site, load it and parse its elements (e.g. Id like to be able to
> access their tables + contents etc.). I thought MSHTML would be a good
> choice and using IHTMLDocument should provide all required functionality.
To
> get the IHTMLDocument one must call the get_document() method of
> IWebBrowser2 - so far my theory.

> But why cant I just use a CComPtr<IWebBrowser2>, call CoCreateInstance()
> and the use its Navigate2() method to access a web site? How can I use it
> in my dll? Or cant I use it at all? Are there any other possibilities?

> Regards

> Markus



Sun, 22 Feb 2004 23:04:49 GMT  
 Use IWebBrowser in COM component
Hi Igor!

Thanks, Ill try it ... looks good :-)


Quote:
> For a UI-less HTML parser, see WalkAll sample. You don't need WebBrowser
for
> this, raw MSHTML is enough.
> --
> With best wishes,
>     Igor Tandetnik



> > Hi everybody!

> > I have a COM compoment (a dll) and within this component Id like to
> access
> > a web site, load it and parse its elements (e.g. Id like to be able to
> > access their tables + contents etc.). I thought MSHTML would be a good
> > choice and using IHTMLDocument should provide all required
functionality.
> To
> > get the IHTMLDocument one must call the get_document() method of
> > IWebBrowser2 - so far my theory.

> > But why cant I just use a CComPtr<IWebBrowser2>, call
CoCreateInstance()
> > and the use its Navigate2() method to access a web site? How can I use
it
> > in my dll? Or cant I use it at all? Are there any other possibilities?

> > Regards

> > Markus



Sun, 22 Feb 2004 23:31:54 GMT  
 Use IWebBrowser in COM component
Hey I'm a novice myself, but MSDN has a sample program which is pretty
simple and to the point. It downloads a web page and displays it, but could
be modified to save it, parse it, etc..

On the MSDN disk:
samples \ MFC \ internet \ tear

--------------------------------------
James Allen Bressem
954-923-0629, 973-760-0620

http://home.sprintmail.com/~1854316/


Quote:
> Hi everybody!

> I have a COM compoment (a dll) and within this component Id like to
access
> a web site, load it and parse its elements (e.g. Id like to be able to
> access their tables + contents etc.). I thought MSHTML would be a good
> choice and using IHTMLDocument should provide all required functionality.
To
> get the IHTMLDocument one must call the get_document() method of
> IWebBrowser2 - so far my theory.

> But why cant I just use a CComPtr<IWebBrowser2>, call CoCreateInstance()
> and the use its Navigate2() method to access a web site? How can I use it
> in my dll? Or cant I use it at all? Are there any other possibilities?

> Regards

> Markus



Thu, 26 Feb 2004 19:00:46 GMT  
 Use IWebBrowser in COM component
http://www.euromind.com/iedelphi/
This site is obviously Delphi, but they have a lot of good
stuff on it and also the guys there are fantastic at
working with IE and COM and stuff like that.  It might
help.
J.

Quote:
>Hi everybody!

>I have a COM compoment (a dll) and within this component
Id like to access
>a web site, load it and parse its elements (e.g. Id
like to be able to
>access their tables + contents etc.). I thought MSHTML
would be a good
>choice and using IHTMLDocument should provide all

required functionality. To
Quote:
>get the IHTMLDocument one must call the get_document()
method of
>IWebBrowser2 - so far my theory.

>But why cant I just use a CComPtr<IWebBrowser2>, call
CoCreateInstance()
>and the use its Navigate2() method to access a web site?
How can I use it
>in my dll? Or cant I use it at all? Are there any other
possibilities?

>Regards

>Markus

>.



Fri, 27 Feb 2004 15:28:38 GMT  
 Use IWebBrowser in COM component
Thanks for the tip, Ill try it ...



Quote:
> Hey I'm a novice myself, but MSDN has a sample program which is pretty
> simple and to the point. It downloads a web page and displays it, but
could
> be modified to save it, parse it, etc..

> On the MSDN disk:
> samples \ mfc \ internet \ tear

> --------------------------------------
> James Allen Bressem
> 954-923-0629, 973-760-0620

> http://home.sprintmail.com/~1854316/



> > Hi everybody!

> > I have a COM compoment (a dll) and within this component Id like to
> access
> > a web site, load it and parse its elements (e.g. Id like to be able to
> > access their tables + contents etc.). I thought MSHTML would be a good
> > choice and using IHTMLDocument should provide all required
functionality.
> To
> > get the IHTMLDocument one must call the get_document() method of
> > IWebBrowser2 - so far my theory.

> > But why cant I just use a CComPtr<IWebBrowser2>, call
CoCreateInstance()
> > and the use its Navigate2() method to access a web site? How can I use
it
> > in my dll? Or cant I use it at all? Are there any other possibilities?

> > Regards

> > Markus



Fri, 27 Feb 2004 20:44:54 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Good books on developing com+ components using c#

2. Using .NET Components in COM

3. Using CDaoDatabase/CDaoRecordset from inside an ATL/MFC COM Component

4. Problem using COM components in VB

5. creating com+ component using atl smartptr

6. Using messagebox to display synchronisation in STA COM component

7. Prevent people from using my COM component

8. How COM components developed for WebClasses are diff from others say used on Desktop

9. Using COM component in non MFC program.

10. using com components developed in vb

11. Categorizing COM Component using IDL

12. Using a VISUAL Basic COM component from within Visual C++

 

 
Powered by phpBB® Forum Software