views:

228

answers:

2

Disclaimer: I'm asking on behalf of a client, and have not witnessed this issue first hand. He has a third party app that produces training media, which his training application presents in a WinForms app through the WebBrowser control.

The interfaces he has been able to access on the WebBrowser control, on the surface of things, don't expose all the information required by the host form to fully integrate with the web application, which is a bit more advanced than basic HTML. He would like to e.g. detect a button click, and information on the state of the web app when that click takes place.

If more is possible that we know with the WebBrowser, please suggest some areas to explore. Otherwise, is there any alternative to the WebBrowser control? Anything from Mozilla that can be hammered into looking like a windows form control but without being so proprietary?

+2  A: 

If you're using an IE control then you can do pretty much anything you want using the HTML object library: msmhtl.dll. You can hook into the IE control and access the DOM, intercept all events and even programmatically intercept the HTML and change it on the fly. But, this is a huge topic.

Here's a link to a demo VB app:

http://www.codeproject.com/KB/vb/kirangoka.aspx?msg=2587205

Google on mshtml and shdocvw and you should find a number of interesting examples.

Alternatively, take a look at WatiN.

Neil Kimber
It is a huge topic, and I've wrestled with it myself several times, but for other reasons. I wish Mozilla would publish an open browser control. This is one of the most persistent reminders of Microsoft's evil monopoly.
ProfK
A: 

i have no idea about "all the information required by the host". I guess it is specific to the web site. The web site needs to expose the information in a predictable way, such as giving the elements ids for easy access.

You may want to redesign the web site and expose some APIs via web service. Using a browser for HTML Parsing isn't a very reliable and scalable.

Sheng Jiang 蒋晟
@Sheng, the problem is that the 'web' content is generated by a third-party app, and not manually crafted.
ProfK
Then you need to study the web site's HTML pattern. A boring task. You need to predict all page variations based on the user's permission and settings, locating the information using trial and error methods like locating a Table by comparing its First Row's first cell's innertext with predefined expression, and upgrade your program when the web site changes the page structure.
Sheng Jiang 蒋晟
It's crossed my mind to inject code for event handlers that stores information, e.g. what link was clicked, and then read and parse the Dom, but that sounds dangerous or clumsy.
ProfK
Yes, and IE does not handle DOM injection that well (you may get operation aborted error)
Sheng Jiang 蒋晟