Click here to Skip to main content
15,899,549 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I want to Know the Way by means of Which we can Get the State of the Browser.

For e.g We are doing some operations and When it Completes the State of the Browser is diaplayed as done.
or When we perform any operation the state is processing.

Any Way/Ideas to implement this?
Posted
Comments
AyushJain1890 15-Mar-13 7:41am    
In This Case Now if We Have our Own already Launched IE Browser and we Want yo Get Instance of the Same on Which we can Perform the Operation Then How we can do that.

ok, this is tricky. you have to write a plugin, to accomplish this for a browser or you have to grab (attach to) the ie process. from within your application, you can host your own ie instance using the provided browser object which would be much easier.

now, dealing with a certain instance of the browser/ie is quite a frustrating experience, because you have to use a bunch of old fashioned interfaces (C/C++) with poor documentation. the rest is mostly about casting or better finding the appropriate classes/interfaces. the following code is not tested, but hints the right direction.
using System.Runtime.InteropServices;
using System.Web;
using Microsoft.Win32;
using mshtml;
using SHDocVw;
[...].object o = null;
InternetExplorer ieInstance = new InternetExplorerClass();
IWebBrowserApp wb = (IWebBrowserApp)ieInstance;
wb.Navigate("http://www.google.de", ref o, ref o, ref o, ref o);
wb.Visible = true;
// wait
while (wb.Busy) ;
HTMLDocument wd = (HTMLDocument)wb.Document;
//HTML-Code
IHTMLDocument2 doc = (IHTMLDocument2)ieInstance.Document;
string sHTML = doc.body.innerHTML;
//or
HTMLDocument htmlDoc = (HTMLDocument)(ieInstance as SHDocVw.WebBrowserClass).Explorer.IWebBrowser_Document;
//inject Script to show message
htmlDoc.ParentWindow.execScript("alert('hello world !!')", "javascript");
// one possible cast
(ieInstance as SHDocVw.InternetExplorer).ReadyState == SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE
// another possible cast
(ieInstance as SHDocVw.WebBrowser_V1).BeforeNavigate += new DWebBrowserEvents_BeforeNavigateEventHandler(this.OnBeforeNavigate);
(ieInstance as SHDocVw.WebBrowser_V1).NavigateComplete += new DWebBrowserEvents_NavigateCompleteEventHandler(BHOIEContextMenu_NavigateComplete);
 
Share this answer
 
In This Case Now if We Have our Own already Launched IE Browser and we Want yo Get Instance of the Same on Which we can Perform the Operation Then How we can do that.

And Do you Have shdocvw.dll available that u can provide
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900