Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
Hi,
 
I am trying to open an IE window from my code using the following:
private void Form1_Load(object sender, EventArgs e)
{
       object sObj = null;
       m_IExplorer = new SHDocVw.InternetExplorerClass();
       m_WebBrowser = (IWebBrowserApp)m_IExplorer;
            
       object sUrl = "www.google.com";
       m_WebBrowser.Navigate((string)sUrl, ref sObj, ref sObj, ref sObj, ref sObj);
       m_WebBrowser.Visible = false;
       int mainHandle = m_IExplorer.HWND;
}

and then in a button click I am opening a new window like this:
private void button1_Click(object sender, EventArgs e)
{
 object flag = 0x1;
 object sObj = null;
 object sUrl = "http://www.yahoo.com";
 m_WebBrowser.Navigate((string)sUrl, ref flag, ref sObj, ref sObj, ref sObj);
 m_WebBrowser.Visible = true;
 int childHandle = m_IExplorer.HWND;
}
So here, at the form load my main window, I intend to have it invisible and only make the child window visible. But what happens is, at the button click when the child window is made visible, both the main and the child window becomes invisible.
 
What I would like to know is how do I get the handle on the new window that is created and just try to make that visible and keep the main window visible property as false.
 
Thanks for your help,
-Bhaskar.
Posted 13-Mar-11 22:23pm
Edited 13-Mar-11 22:27pm
JF201553.3K
v2
Comments
JF2015 at 14-Mar-11 3:27am
   
Added code formatting.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I have found a solution to this problem. In the button click I just have to remove the line:
 
m_WebBrowser.Visible = true;
 
The navigate command by default opens up a visible page and there is no explicit need to make it visible. Doing it explicitly makes both the windows visible.
 
Thanks,
-Bhaskar
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 14 Mar 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100