Interesting IntelliSense behaviour with Webbrowser

K

kimiraikkonen

Hi there,
I needed to use MouseOver event on Webbrowser which is NOT provided by
webbrowser control natively(what a disappointment), so i decided to go
with another route to simulate this like:


////////////////////////////////////////////////
Public Sub DisplayHyperlinks(ByVal sender As Object, ByVal e As
System.Windows.Forms.HtmlElementEventArgs)

' My codes here

End Sub

Private Sub webbrowser1_DocumentCompleted(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles
webbrowser1.DocumentCompleted

' Here is my question
' Although intellisense doesn't recognize "Document", but i'm still
able to compile
' and use this addhandler syntax without any build or runtime errors
AddHandler webbrowser1.Document.MouseOver, AddressOf
Me.DisplayHyperlinks

End Sub
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Shortly:
"AddHandler webbrowser1.Document.MouseOver, AddressOf
Me.DisplayHyperlinks"

...that syntax claims no error when it's built / compiled, but
IntelliSense doesn't recognize "Document" after "webbrowser1" object.

Why?

I hope i have explained enoug clear,
Thanks,

Onur Güzel
 
L

Lloyd Sheen

Hi there,
I needed to use MouseOver event on Webbrowser which is NOT provided by
webbrowser control natively(what a disappointment), so i decided to go
with another route to simulate this like:


////////////////////////////////////////////////
Public Sub DisplayHyperlinks(ByVal sender As Object, ByVal e As
System.Windows.Forms.HtmlElementEventArgs)

' My codes here

End Sub

Private Sub webbrowser1_DocumentCompleted(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles
webbrowser1.DocumentCompleted

' Here is my question
' Although intellisense doesn't recognize "Document", but i'm still
able to compile
' and use this addhandler syntax without any build or runtime errors
AddHandler webbrowser1.Document.MouseOver, AddressOf
Me.DisplayHyperlinks

End Sub
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Shortly:
"AddHandler webbrowser1.Document.MouseOver, AddressOf
Me.DisplayHyperlinks"

....that syntax claims no error when it's built / compiled, but
IntelliSense doesn't recognize "Document" after "webbrowser1" object.

Why?

I hope i have explained enoug clear,
Thanks,

Onur Güzel

What are you trying to get. If you are trying to get a link when the mouse
is over one on a page you can use the StatusTextChanged event to get links.

LS
 
K

kimiraikkonen

What are you trying to get. If you are trying to get a link when the mouse
is over one on a page you can use the StatusTextChanged event to get links.

LS

Yes, but that doesn't provide when mouse is over an image which is my
goal about retrieving image location.

However, i did it using "AddHandler webbrowser1.Document.MouseOver,
AddressOf Me.DisplayHyperlinks" but my question and wonder was just
about why Intellisense doesn't offer "Document" after webbrowser1
while you're typing syntax manually instead of pasting from
somewhere,you can test it. Though IntelliSense doesn't offer and
recognize "Document" after "webbrowser1" object, if i type it without
addhandler keyword just to use its members somewhere else it sees
"Document" member of "webbrowser1" object with no problem, but as i
said if paste the code without manually typing, there are no errors
reported even on building my application.

That's weird of IntelliSense.

Thanks,

Onur
 
K

kimiraikkonen

Hi Steve,
Yes, if i use this syntax, intellisense recognizes every object with no
problem.
Dim x As HtmlDocument = WebBrowser1.Document
AddHandler x.MouseOver, AddressOf Me.DisplayHyperlinks


But if i use in this way, it doesn't show "Document" property just after
"Webbrowser1"(it's impatient that it expects an event), though that code is
compiled and it works as it should:

AddHandler kimibrowser.Document.MouseOver, AddressOf Me.DisplayHyperlinks

Thanks for the care,

Onur Güzel
 
K

kimiraikkonen

Yeah, a straight code like:

Me.Webbrowser1.Document... has also no recognition problem by Intellisense
on my machine,too.

The problem with Intellisense was the syntax i was using:
AddHandler webbrowser1.Document.MouseOver, AddressOf Me.DisplayHyperlinks


Thanks,

Onur Güzel
 
L

Lloyd Sheen

Hi there,
I needed to use MouseOver event on Webbrowser which is NOT provided by
webbrowser control natively(what a disappointment), so i decided to go
with another route to simulate this like:


////////////////////////////////////////////////
Public Sub DisplayHyperlinks(ByVal sender As Object, ByVal e As
System.Windows.Forms.HtmlElementEventArgs)

' My codes here

End Sub

Private Sub webbrowser1_DocumentCompleted(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles
webbrowser1.DocumentCompleted

' Here is my question
' Although intellisense doesn't recognize "Document", but i'm still
able to compile
' and use this addhandler syntax without any build or runtime errors
AddHandler webbrowser1.Document.MouseOver, AddressOf
Me.DisplayHyperlinks

End Sub
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Shortly:
"AddHandler webbrowser1.Document.MouseOver, AddressOf
Me.DisplayHyperlinks"

....that syntax claims no error when it's built / compiled, but
IntelliSense doesn't recognize "Document" after "webbrowser1" object.

Why?

I hope i have explained enoug clear,
Thanks,

Onur Güzel

Finally got a chance to test this and I do not see the problem you describe.

The app I used to test is one that takes a list of URL's and in a tabcontrol
, creates a new tabpage, a new WebBrowser, and then adds the WebBrowser to
the tabpage and the tabpage to the tabcontrol.

My code is (for the webbrowser) is just

Dim wc As New WebBrowser

Now when I type

AddHandler wc. (now I get document) . and I get a list of not just events
but properties and functions as well.

I can select MouseOver from the list and all is good.

I am using VS 2008 Pro.

LS
 
K

kimiraikkonen

Hi Lloyd,
I'm using VB 2005 express and i placed Webbrowser control from toolbox into
my form, and it doesn't recognize Document property if i use it in a
"Addhandler" syntax.

Addhandler webbrowser.<i don't get Document, it expects an event as
well>.MouseOver,AddressOf Me.DisplayHyperlinks

As you're using VS 2008, maybe that may have been fixed in 2008 or you need
to place Webbrowser control to your form instead of manually creating
WebBrowser instance.

And of course when i use Webbrowser1 object elsewhere like in a sub or in a
button1.click event there's no problem with intellisense

Webbrowser1.Document.members...... (no problem)

The problem was recognizing Document property of Webbrowser within Addhandler.

Plus, Steve's suggestion worked to make Webbrowser recognize all the objects:
Dim x As HtmlDocument = WebBrowser1.Document
AddHandler x.MouseOver, AddressOf Me.DisplayHyperlinks

Thanks,

Onur
 
L

Lloyd Sheen

kimiraikkonen said:
Hi Lloyd,
I'm using VB 2005 express and i placed Webbrowser control from toolbox
into
my form, and it doesn't recognize Document property if i use it in a
"Addhandler" syntax.

Addhandler webbrowser.<i don't get Document, it expects an event as
well>.MouseOver,AddressOf Me.DisplayHyperlinks

As you're using VS 2008, maybe that may have been fixed in 2008 or you
need
to place Webbrowser control to your form instead of manually creating
WebBrowser instance.

And of course when i use Webbrowser1 object elsewhere like in a sub or in
a
button1.click event there's no problem with intellisense

Webbrowser1.Document.members...... (no problem)

The problem was recognizing Document property of Webbrowser within
Addhandler.

Plus, Steve's suggestion worked to make Webbrowser recognize all the
objects:
Dim x As HtmlDocument = WebBrowser1.Document
AddHandler x.MouseOver, AddressOf Me.DisplayHyperlinks

Thanks,

Onur
--
Best regards,

Onur Güzel
(e-mail address removed)

I changed my project for a test by adding a webbrowser to the form. I can
still use the addHandler to get the intellisense that is correct and
includes MouseOver. Again I am using VS 2008 so I don't know if that is the
difference.

I don't have any extra references or anything out of the ordinary.

LS
 
K

kimiraikkonen

Could it be that your reference link to the MSHTML library is corrupted?

It doesn't seem any reference to MSHTML library, i use Webbrowser
control.

However, as i stated, pasting the whole code claims no error even on
compiling about "Document" when it's used with Addhandler, and just
IntelliSense doesn't recognize Document after Addhandler
webbrowser.Document...., except Steve's workaround that is described
in previous posts which is worked.

Thanks,

Onur Güzel
 

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