473,779 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using the webbrowser control

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
DocumentComplet e 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
1 2659
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.co m

"boxim" <sa*********@ya hoo.co.uk> wrote in message
news:uJ******** *****@TK2MSFTNG P10.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 DocumentComplet e 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2377
by: dxben | last post by:
I am considering a situation where I have (n) number of form windows, each with an instance of the Microsoft Web Browser Control (IE) on each form. In each web browser control is an HTML page that has a Java applet. This is the only way I am aware of to get a Java applet to paint within a .NET Forms window. Given that scenario I am trying to determine whethere there would be one Java VM loaded for all of the (n) applets inside the (n) MS...
10
2147
by: Selden McCabe | last post by:
I'm trying to display some HTML on a form in a VB.Net project. I've referenced the COM WebBrowser control, and put an instance of it on my form. But during the Form_Load, I'm getting the following error: The code generator inserted the following line of code in the form (wbReport is the name of the WebBrowser control)
8
3420
by: Prosperz | last post by:
Hi, I would like to make thumbnails of web page by capture content of a WebBrowser. By example, capture http://www.google.com. I used WebBrowser control with Framework 2.0. I try this : *************************************************
5
6582
by: mabond | last post by:
Hi recently read a posting and reply about Excel processs still running after the Appliction.Quit was called. Thought I might be able to use the same (System.Runtime.InteropServices.Marshal.ReleaseComObject(exApplication)) to solve my problem but could not. Background : My app uses a WebBrowser control to display to the user the contents of an Excel spreadsheet.:
4
12010
by: Steve Richter | last post by:
I would like to build an HTML stream as a string and have the WebBrowser control render that HTML. Then on PostBack, or whatever it is called, I would like my code to be the one that receives what the WebBrowser control is sending. Effectively, my code would be the web server and the WebBrowser control would be the web client. All the examples I am seeing have the WebBrowser control being directed to a URL from which to get the HTML...
1
4508
by: JP2006 | last post by:
I'm trying to write a control that will take a screen capture of a particular website when a user submits a form in a web application; one of the form fields is for a URL - the control needs to get an image of that web site so that it can be displayed later as a thumbnail image. I have code for taking a normal screen capture using GDI+ which works fine. What I am now trying to do is to modify it so the screen capture is of a remote...
6
13713
by: Leon | last post by:
Hi there, I am trying to use the WebBrowser Control in a form which is being started in an own thread by the main form of my application. Unfortunately I am always getting an error in InitializeComponents stating that the ActiveX-Control 8856f961-340a-11d0-a96b-00c04fd705a2 cannot be initiated because the current thread isn't a single-thread apartment. Is there way of using the webbrowser control in multi threaded applications in .Net...
5
8078
by: kimiraikkonen | last post by:
Hi, I couldn't find a necessary class which shows when mouse hovers on a link in Webbrowser control. Think of there's a status bar(text), when mouse comes on a link, the URL must be shown in this status bar. How can i do this? Thanks.
0
3266
by: =?Utf-8?B?Q29kZVJhem9y?= | last post by:
I am converting a windows application which contains a web browser control into an ASP.net application. The Windows project references all manner of html controls in the WebBrowser control and retrieves values using the HtmlControlCollection class etc. I was hoping I was going to be able to work with the Windows.Forms.WebBrowser object from inside my ASP.net webform by simply adding a reference to System.Windows.Forms and doing code...
0
10302
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10071
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8958
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.