By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,310 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,310 IT Pros & Developers. It's quick & easy.

Using the webbrowser control

P: n/a
Hi All,

Just after some other opinions really....

We're writing this application that in places implements the WebBrowser
control to make certain bits look nicer as well as make things quicker to
develop. To write each page as an owner drawn control would take ages.

The only thing that bothers me is the comminication between the browser
control and the main application. We're using the mshtml.dll to hook events
to buttons and finding the objects in the HTML pages by extending the DOM
and adding our own attributes to certain HTML elements - this is sort of
ok - but it seems a bit flakey. I.e. lots of re-hooking of HTML element
events, and periodically some elements don't re-hook to a handler after the
HTML document is refreshed.

Obviously, the hooking of element events to methods in my C# application can
occure only after the HTML Document has finished loading - so i do it on the
DocumentComplete event. But the page is obviously loaded by the WebBrowser
control by one or more threads, so do I need to build in thread safety when
processing these events?

I just need someone really to say, yes you're doing it the right way.... if
I am?

TIA

Sam Martin
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sam,

Don't worry about the threading. The WebBrowser control, because it is
a visual control, is a Single Threaded component. This means that all
access to it is serialized through one thread. Consequently, all events
coming out of it should occur on that same thread as well. Because of this,
you only have to worry about your components being accessed on the UI
thread.

As for finding the objects in the HTML pages, I don't think you should
add your own attributes. I think that you should use the ID attribute and
set it to something unique, using your own scheme.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"boxim" <sa*********@yahoo.co.uk> wrote in message
news:uJ*************@TK2MSFTNGP10.phx.gbl...
Hi All,

Just after some other opinions really....

We're writing this application that in places implements the WebBrowser
control to make certain bits look nicer as well as make things quicker to
develop. To write each page as an owner drawn control would take ages.

The only thing that bothers me is the comminication between the browser
control and the main application. We're using the mshtml.dll to hook events to buttons and finding the objects in the HTML pages by extending the DOM
and adding our own attributes to certain HTML elements - this is sort of
ok - but it seems a bit flakey. I.e. lots of re-hooking of HTML element
events, and periodically some elements don't re-hook to a handler after the HTML document is refreshed.

Obviously, the hooking of element events to methods in my C# application can occure only after the HTML Document has finished loading - so i do it on the DocumentComplete event. But the page is obviously loaded by the WebBrowser control by one or more threads, so do I need to build in thread safety when processing these events?

I just need someone really to say, yes you're doing it the right way.... if I am?

TIA

Sam Martin

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.