473,405 Members | 2,344 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,405 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 16 '05 #1
5 2810
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 16 '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 16 '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 16 '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 16 '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 16 '05 #6

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...
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...
7
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...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.