Accessing and using an ActiveX from inside a HTML page hosted insidea WebBrowser control

N

nano2k

Hi.

I have a page that is hosted by a WebBrowser control that is "hosted"
by a WinForms.
The page displays an ActiveX control.

I need, from C# code to access and manipulate the ActiveX control. I
already managed to get a reference to the HTMLObjectElementClass
object, but I need to somehow get the right reference to the ActiveX
object itself so that I will be able to invoke directly it's methods,
like:


myActiveX.Load();

To be more specific. Let's say we have this HTML page:


<html><BODY><table><tr><td> <object classid=clsid:
464623dc-4d81-11dc-8314-0800200c9a66 id='myControl' width='660',
height='500' > <PARAM NAME='Host' VALUE='192.168.3.100'/> <PARAM
NAME='HttpPort' VALUE='80'/> <PARAM NAME='RTSPPort' VALUE='554'/>
<PARAM NAME='RTSPoverHTTP' VALUE='0'/> <PARAM NAME='RTSPoverTCP'
VALUE='0'/> <PARAM NAME='VFormat' VALUE='96'/> <PARAM
NAME='G72640PT' VALUE='98'/> said:
<PARAM NAME='AMRPT' VALUE='101'/> <PARAM NAME='UIMode' VALUE='0'/
<PARAM NAME='MediaUsername' VALUE='zozo'/> <PARAM
NAME='MediaPassword' VALUE='zozo'/> </object></td></tr></table></
body></html>

I get a reference to the hmtl element like this:

HTMLDocumentClass doc = webBrowser1.Document.DomDocument as
mshtml.HTMLDocumentClass;HTMLObjectElementClass myControl =
doc.all.item("myControl", 0) as HTMLObjectElementClass;

From myControl I need to get a reference to the underlying COM object
with the appropriate type so that I can call methods like this:


myControlCOM.Load();

Thanks.
 
N

nano2k

Hi.

I have a page that is hosted by a WebBrowser control that is "hosted"
by a WinForms.
The page displays an ActiveX control.

I need, from C# code to access and manipulate the ActiveX control. I
already managed to get a reference to the HTMLObjectElementClass
object, but I need to somehow get the right reference to the ActiveX
object itself so that I will be able to invoke directly it's methods,
like:

myActiveX.Load();

To be more specific. Let's say we have this HTML page:

<html><BODY><table><tr><td>       <object classid=clsid:
464623dc-4d81-11dc-8314-0800200c9a66 id='myControl' width='660',
height='500' >               <PARAM NAME='Host' VALUE='192.168.3.100'/>                <PARAM
NAME='HttpPort' VALUE='80'/>         <PARAM NAME='RTSPPort'VALUE='554'/>
<PARAM NAME='RTSPoverHTTP' VALUE='0'/>            <PARAM NAME='RTSPoverTCP'
VALUE='0'/>          <PARAM NAME='VFormat' VALUE='96'/>                <PARAM


NAME='MediaPassword' VALUE='zozo'/>  </object></td></tr></table></
body></html>

I get a reference to the hmtl element like this:

HTMLDocumentClass doc = webBrowser1.Document.DomDocument as
mshtml.HTMLDocumentClass;HTMLObjectElementClass myControl =
doc.all.item("myControl", 0) as HTMLObjectElementClass;

From myControl I need to get a reference to the underlying COM object
with the appropriate type so that I can call methods like this:

myControlCOM.Load();

Thanks.

Hi all

Just found the answer here:

http://www.sahirshah.com/CSharp/objcall.html

Hope it helps someone else.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top