Can't Add Reference to MSHTML

C

cellocoder

I have tried it in Vb2005, vb2008, and CS2008. The program just hangs
up with an hour glass. I downloaded a program with that reference
added and it didn't work. I can add it to vb6 with no problem. I have
Microsoft HTML Object Library version 4.0. I can add references to
other objects.

What I actually need is a webbrowser on my a form. When someone
highlights text, I want to have that text, or better, a reference to
the html element which highlighted available to my vb.net code. I use
vb2008 express edition. I have read that this is not possible with the
2.0 webbrowser alone, but only by adding an unmanaged com object. I
would rather not do that, but tried and failed anyway.
 
K

kimiraikkonen

I have tried it in Vb2005, vb2008, and CS2008. The program just hangs
up with an hour glass. I downloaded a program with that reference
added and it didn't work. I can add it to vb6 with no problem. I have
Microsoft HTML Object Library version 4.0. I can add references to
other objects.

What I actually need is a webbrowser on my a form. When someone
highlights text, I want to have that text, or better, a reference to
the html element which highlighted available to my vb.net code. I use
vb2008 express edition. I have read that this is not possible with the
2.0 webbrowser alone, but only by adding an unmanaged com object. I
would rather not do that, but tried and failed anyway.

Having VB 2005 express, it hangs, too. Don't know why.

By the way, also adding WIA Video Preview Class to toolbox from "COM
components tab" makes Visual Studio crash and quit suddenly by itself
on VB and C# both.

My wild guess, the libraries may have some uncompatible unmanaged code
that causes problem :(

Onur
 
K

kimiraikkonen

Having VB 2005 express, it hangs, too. Don't know why.

By the way, also adding WIA Video Preview Class to toolbox from "COM
components tab" makes Visual Studio crash and quit suddenly by itself
on VB and C# both.

My wild guess, the libraries may have some uncompatible unmanaged code
that causes problem :(

Onur

Note and little correction, deleting WIA Video Preview Class activeX
control from form makes VS crash/quit suddenly, not adding.

For your problem, to highlight text on your webbrowser, you can hook
IE's find findow using
SendKeys.Send("^f")


Thanks

Onur
 
C

cellocoder

For your problem, to highlight text on your webbrowser, you can hook
IE's find findow using
SendKeys.Send("^f")

What I need is for the user to select by highlighting text, which
doesn't involve Find. You're the only person I can find who has had
crashes putting COM into .NET. It seems to work for everybody else.
 
K

kimiraikkonen

What I need is for the user to select by highlighting text, which
doesn't involve Find. You're the only person I can find who has had
crashes putting COM into .NET. It seems to work for everybody else.

Hi,
Based on my understanding, if you want to get selected(highlighted)
text in browser using Webbrowser control, the unique solution i've
generated is:

' First select some text on a webpage
' Copy selected text to clipboard using:
webbrowser1.Document.ExecCommand("copy", False,
webbrowser1.Document.ActiveElement.All)

' Finally get text from clipboard
Clipboard.GetText.ToString


Note: It's unfortunate that webbrowser control doesn't provide
"selection" object natively. And by the way, there are much more COM-
based ActiveX controls or classes that crashes VS when they're being
added or removed or used on VS. In some cases .NET components /
component tab (references) aren't enough as COM tab, but as i stated
COM tab items are completely instable on VB.NET / VB 2005 express at
least.

Hope this helps,

Onur Güzel
 
C

cellocoder

Hi,
Based on my understanding, if you want to get selected(highlighted)
text in browser using Webbrowser control, the unique solution i've
generated is:

' First select some text on a webpage
' Copy selected text to clipboard using:
webbrowser1.Document.ExecCommand("copy", False,
webbrowser1.Document.ActiveElement.All)

' Finally get text from clipboard
 Clipboard.GetText.ToString

Note: It's unfortunate that webbrowser control doesn't provide
"selection" object natively. And by the way, there are much more COM-
based ActiveX controls or classes that crashes VS when they're being
added or removed or used on VS. In some cases .NET components /
component tab (references) aren't enough as COM tab, but as i stated
COM tab items are completely instable on VB.NET / VB 2005 express at
least.

Hope this helps,

Onur Güzel

Thanks Onur. If I understand this right, it is possible to "walk the
DOM tree" without using MSHTML. I will work on this. There are many
people out there who say you need MSHTML for that. One other question:
your third prarameter is "webbrowser1.Document.ActiveElement.All".
The documentation defines it thus:

value: The value to assign using the command. Not applicable for all
commands.

Do you know what this actually means?

Btw, I was in Ankar for a couple days. Awesome people there. The
kindest in the world. I almost stayed.
 
K

kimiraikkonen

Thanks Onur. If I understand this right, it is possible to "walk the
DOM tree" without using MSHTML. I will work on this. There are many
people out there who say you need MSHTML for that. One other question:
your third prarameter is "webbrowser1.Document.ActiveElement.All".
The documentation defines it thus:

value: The value to assign using the command. Not applicable for all
commands.

Do you know what this actually means?

Btw, I was in Ankar for a couple days. Awesome people there. The
kindest in the world. I almost stayed.

Hi cellocoder,
I used "webbrowser1.Document.ActiveElement.All" to copy every kind of
element to clipboard including pictures and text data. However
changing "All" to "InnerText" didn't change much things based on my
testings, maybe it's site-specific.

For the "value" parameter's description, again my guess, that the
command ("copy") will use this parameter to make the work, in this
case "copy" command copies "webbrowser1.Document.ActiveElement.All"
data to clipboard. I hope there were much better ways to handle
document like old MSHTML object, but it hangs when you reference it on
VB 2005 express, too.

BTW, you visited Ankara, the capital city of Turkey? I went there for
once. I hope you enjoyed ! :)

Thanks,

Onur
 

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