WindowStateChanged not being fired in Internet Explorer BHO

NavigateComplete, DocumentComplete, etc work just fine but for some reason WindowStateChanged doesn't. I am testing with IE9. Has this event been deperecated?

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);

        }

...

Answers


Took me half a day but I got it.

By default VS embeds SHDocVw into your BHO, and even though it works, some of the handlers don't fire. I guess IE ends up using a different SHDocVw?

Anyway. by setting embed interop to 'false' and registering it with GAC, the events start firing again. All of them.


Need Your Help

"The iPhone could not be synced because this computer is no longer authorized for purchased items that are on this iPhone:

ios authorization itunes ipa

I have an app in development and need to load the latest IPA for testing, a process performed through iTunes, like syncing anything else. When I try and sync I get the message, "The iPhone could no...

While porting a windows application to web, is it better to stick to conventional web technologies or adoping RIA is wise?

silverlight extjs browser-plugin web-technologies

The web based application I am working on currently is a port from a windows application. This application is very data intensive. There are scores of modules and each of these modules have number of