473,320 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Getting a reference to an "object" from the WebBrowser Control?

Hiya,

I'm using mshtml and the web browser control to embed an OLE object in my
..NET application.

What I want to do is get a reference to the "object" embedded therein:

The HTML looks something like this:

<html>
<body>
<object classid="clsid:260AACA0-F963-101B-8955-0000C0DCD465"
id="TgControl" width="100%" height="100%" border="1" ></object>
</body>
</html>

I am loading the above HTML with the Browser.Navigate2 command and all is
well. Now, I can fetch the Document Object Model of the web page using:

Dim myDoc As HTMLDocument = New HTMLDocumentClass
myDoc = CType(Browser.Document, HTMLDocument)

But how can I get a reference to the actual embedded item "TgControl" from
the object model?

Any hints greatly appreciated.

Robin
Nov 20 '05 #1
7 6904
Hi Robin,

When I was you I would start with it in VB.net with Option Strict of.

A sample to get the first href (This is all with early binding)
Watch typos or other errors I copied it from a class however not complete so
someparts can be very good wrong.

It is just to give you the idea.

I hope this helps?

Cor

myDoc = CType(Browser.Document, mshtml.IHTMLDocument2)
For i as integer = 0 To MyDoc.all.length - 1
Dim hElm as mshtml.IHTMLElement= DirectCast(MyDoc.all.item(i),
mshtml.IHTMLElement)
If (hElm.tagName = "a") Then
If Not DirectCast(hElm, mshtml.IHTMLAnchorElement).href Is Nothing
Then
hrefname = DirectCast(hElm,
mshtml.IHTMLAnchorElement).href.ToString
'do Something
End if
End If
next

I'm using mshtml and the web browser control to embed an OLE object in my
.NET application.

What I want to do is get a reference to the "object" embedded therein:

The HTML looks something like this:

<html>
<body>
<object classid="clsid:260AACA0-F963-101B-8955-0000C0DCD465"
id="TgControl" width="100%" height="100%" border="1" ></object>
</body>
</html>

I am loading the above HTML with the Browser.Navigate2 command and all is
well. Now, I can fetch the Document Object Model of the web page using:

Dim myDoc As HTMLDocument = New HTMLDocumentClass
myDoc = CType(Browser.Document, HTMLDocument)

But how can I get a reference to the actual embedded item "TgControl" from
the object model?

Any hints greatly appreciated.

Robin

Nov 20 '05 #2
Ok, I can see what you are doing here Cor, but the problem is I have an
object embedded of the class 260AACA0-F963-101B-8955-0000C0DCD465 - what I
want to do is get an IntPtr (or something) to this data blob so that I can
manipulate it while it is embedded in the web browser control.

By looking at the properties of "myDoc" with the debugger, I can see that
the HTML I have shown below results in the "Applet" collection having a
single item in it. I'm guessing this is something to do with my TgControl
object. Now what I want is to get access to this object so I can manipulate
it.

Does this make sense?

Thanks.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi Robin,

When I was you I would start with it in VB.net with Option Strict of.

A sample to get the first href (This is all with early binding)
Watch typos or other errors I copied it from a class however not complete so someparts can be very good wrong.

It is just to give you the idea.

I hope this helps?

Cor

myDoc = CType(Browser.Document, mshtml.IHTMLDocument2)
For i as integer = 0 To MyDoc.all.length - 1
Dim hElm as mshtml.IHTMLElement= DirectCast(MyDoc.all.item(i),
mshtml.IHTMLElement)
If (hElm.tagName = "a") Then
If Not DirectCast(hElm, mshtml.IHTMLAnchorElement).href Is Nothing
Then
hrefname = DirectCast(hElm,
mshtml.IHTMLAnchorElement).href.ToString
'do Something
End if
End If
next

I'm using mshtml and the web browser control to embed an OLE object in my .NET application.

What I want to do is get a reference to the "object" embedded therein:

The HTML looks something like this:

<html>
<body>
<object classid="clsid:260AACA0-F963-101B-8955-0000C0DCD465"
id="TgControl" width="100%" height="100%" border="1" ></object>
</body>
</html>

I am loading the above HTML with the Browser.Navigate2 command and all is well. Now, I can fetch the Document Object Model of the web page using:

Dim myDoc As HTMLDocument = New HTMLDocumentClass
myDoc = CType(Browser.Document, HTMLDocument)

But how can I get a reference to the actual embedded item "TgControl" from the object model?

Any hints greatly appreciated.

Robin


Nov 20 '05 #3
Elp

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:ca*******************@news.demon.co.uk...
Hiya,

I'm using mshtml and the web browser control to embed an OLE object in my
.NET application.

What I want to do is get a reference to the "object" embedded therein:


No idea regarding your question but wouldn't it be easier to locate the .dll
or .ocx file containing this object and adding it directly on your form
instead of passing through the Web Browser control? Not all IE embeddable
objects can be ambedded in a Window Form but i've done that succesfully with
quite a few of them.
Nov 20 '05 #4
Hi Robin,

Nice idea, however I would first try with that sample I gave you try to get
the information.
Probably is the equivalent from IHTMLAnchorElement for the object
IHTMLObjectElement.
I was currious and I typed it in in MSDN, and there it was :)

http://msdn.microsoft.com/library/de...ement/type.asp

Every element has something like that conform the DOM. From than I would do
that other step to get to the real applet object in mem, however from that I
donnot know how, although it sounds very interesting.

Cor
Nov 20 '05 #5
Cor and Robin,

If you can get the IHTMLObjectElement interface, then you can use the
object property to get the actual object (and cast it to whatever you wish).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
Hi Robin,

Nice idea, however I would first try with that sample I gave you try to get the information.
Probably is the equivalent from IHTMLAnchorElement for the object
IHTMLObjectElement.
I was currious and I typed it in in MSDN, and there it was :)

http://msdn.microsoft.com/library/de...ement/type.asp
Every element has something like that conform the DOM. From than I would do that other step to get to the real applet object in mem, however from that I donnot know how, although it sounds very interesting.

Cor

Nov 20 '05 #6
Cheers guys - I didn't see the object property. Actually, the
HTMLObjectElement class in mshtml does not have the object property,
although the IHTMLObjectElement interface does. This is what threw me!

Now its all working well. Thanks.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2***************@TK2MSFTNGP11.phx.gbl...
Cor and Robin,

If you can get the IHTMLObjectElement interface, then you can use the
object property to get the actual object (and cast it to whatever you wish).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
Hi Robin,

Nice idea, however I would first try with that sample I gave you try to get
the information.
Probably is the equivalent from IHTMLAnchorElement for the object
IHTMLObjectElement.
I was currious and I typed it in in MSDN, and there it was :)

http://msdn.microsoft.com/library/de...ement/type.asp

Every element has something like that conform the DOM. From than I would

do
that other step to get to the real applet object in mem, however from

that I
donnot know how, although it sounds very interesting.

Cor


Nov 20 '05 #7
oh please don't go there. That couldn't be done so we decided to create an
ActiveX control by adding the required interfaces to our OLE component. Hey
presto - shaggage! WinForms doesn't seem to like it very much, particularly
the out-of-processness of it. We get deadlock. So, as a last resort (well
not actually, a last resort would be scrapping the current OLE control and
totally re-writing the suite, which would take about 2 years) we are
embedding into a browser. If that doesn't work, embedding into Microsoft
Word within a browser, etc.
"Elp" <ro********@REMOVEME.hotmail.com> wrote in message
news:eW**************@tk2msftngp13.phx.gbl...

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:ca*******************@news.demon.co.uk...
Hiya,

I'm using mshtml and the web browser control to embed an OLE object in my .NET application.

What I want to do is get a reference to the "object" embedded therein:
No idea regarding your question but wouldn't it be easier to locate the

..dll or .ocx file containing this object and adding it directly on your form
instead of passing through the Web Browser control? Not all IE embeddable
objects can be ambedded in a Window Form but i've done that succesfully with quite a few of them.

Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Pablo J Royo | last post by:
Hello: i have a function that reads a file as an argument and returns a reference to an object that contains some information obtained from the file: FData &ReadFile(string FilePath); But ,...
3
by: Kam | last post by:
Hi! When I am trying to drag user controls or any controls from the Toolbox to a form in some of my projects I get a dialog messages: (Microsoft Deployment Environment) "Object reference not...
4
by: Tim Johnson | last post by:
Hello All: I would like to expand upon the typeof operator. Using 'typeof' I can distinguish between string and array for instance, because typeof returns "object" for array. How can I...
2
by: samlee | last post by:
// create an object Control obj=new Control(); // How to write c# code to achieve the following pseudo code? // use an integer to represent an obj int temp=(int)obj; // later recover original...
5
by: Robin Tucker | last post by:
Hiya, I'm using mshtml and the web browser control to embed an OLE object in my ..NET application. What I want to do is get a reference to the "object" embedded therein: The HTML looks...
1
by: Chris Magoun | last post by:
I suddenly received an unexpected error in my project. I have been working on this project for some time without this issue. Nothing has changed in the form that caused the exception. A little...
35
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an...
0
by: Tamer Ibrahim | last post by:
Hi, Sometimes, I got the following error message when I use ajax calendar control on some aspx pages : Object reference not set to an instance of an object. Description: An unhandled exception...
4
by: My Pet Programmer | last post by:
Ok guys, I'm really looking for someone to tell me how bad a hack this is, and if I'm close to where I should be with it. The basic situation is that I have a class which creates a basic...
3
by: Sarah | last post by:
Hi - Please be gentle. I am quite new to visual basic, but I have been going through tutorials and reading up. I found a code snippet on the internet that I wanted to see if I could re-purpose...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.