IWebBrowser2.Navigate opens second window
- by Sam Barham
The following code, on Vista with Internet Explorer 7, opens two windows (the one I create, and then a second one when Navigate is called, which is the one that the file appears in). This doesn't happen in Internet Explorer 8, or on XP as far as I know. Any idea how I can stop it doing that?
SHDocVw.InternetExplorerClass ieObject = (SHDocVw.InternetExplorerClass)this.ieObject;
if (this.ieObject == null)
{
ieObject = new SHDocVw.InternetExplorerClass();
this.ieObject = ieObject;
}
SHDocVw.IWebBrowser2 browserApp = (SHDocVw.IWebBrowser2)this.ieObject;
object empty = System.Reflection.Missing.Value;
browserApp.Visible = true;
User32.SetForegroundWindow(new IntPtr(browserApp.HWND));
browserApp.Navigate(filePath, ref empty, ref empty, ref empty, ref empty);