1
NavigateComplete,DocumentComplete等工作得很好,但由於某種原因,WindowStateChanged沒有。我正在測試IE9。這個事件是否已被廢棄?WindowStateChanged不在Internet Explorer中被觸發BHO
public class BHO : IObjectWithSite, IOleCommandTarget
{
IWebBrowser2 browser = null;
int version = 9;
void OnNavigateComplete2(object pDisp, ref object URL)
{
if (!ReferenceEquals(pDisp, browser))
{
}
else
{
var document = browser.Document as IHTMLDocument2;
var window = document.parentWindow;
Debug.WriteLine(version + "MainURL: " + URL.ToString());
}
}
void OnWindowStateChanged(uint dwWindowStateFlags, uint dwValidFlagsMask)
{
version = version * 2; //never hit
Debug.WriteLine(version);
}
#region Implementation of IObjectWithSite
int IObjectWithSite.SetSite(object site)
{
Debug.WriteLine("SetSite!");
if (site != null)
{
browser = (IWebBrowser2)site;
((DWebBrowserEvents2_Event)browser).NavigateComplete2 +=
new WebBrowserEvents2_NavigateComplete2EventHandler
(this.OnNavigateComplete2);
((DWebBrowserEvents2_Event)browser).WindowStateChanged +=
new WebBrowserEvents2_WindowStateChangedEventHandler
(this.OnWindowStateChanged);
}
...