I have noticed that if I enumerate (through interop) the collection of
windows
implementing IWebBrowser2, that the HWND property will throw a
COMException
(E_FAIL) on MSN Explorer-type windows.  See [1] below.

Can anyone offer an explanation as to why and know of a workaround for
comparing a HWND obtained from WindowFromPoint?

Thanks,

Kollen

[1] C#

SHDocVw.ShellWindowsClass swcCollection = new
SHDocVw.ShellWindowsClass();

foreach (SHDocVw.IWebBrowser2 wb in swcCollection)
{
    if (wb.Parent != null)
    {
        try
        {
            if (hWnd == (IntPtr)wb.HWND)  // throws here
            {
                // We have a match...
            }
        }
        catch (System.Runtime.InteropServices.COMException ce)
        {

        }
    }
}

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to