Internet Explorer对象-navOpenInNewWindow [英] Internet Explorer Object - navOpenInNewWindow

查看:173
本文介绍了Internet Explorer对象-navOpenInNewWindow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试使用以下代码从我的代码中打开IE窗口:

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


所以在这里,在窗体加载主窗口时,我打算使其不可见,而仅使子窗口可见.但是发生的是,在子窗口显示为可见状态时,单击按钮时,主窗口和子窗口都变为不可见.

我想知道的是如何获取创建的新窗口上的句柄,然后尝试使其可见并保持主窗口的可见属性为false.

感谢您的帮助,
-Bhaskar.


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.

推荐答案

我找到了解决此问题的方法.在按钮中,我只需要删除以下行:

m_WebBrowser.Visible = true;

默认情况下,navigation命令会打开一个可见页面,并且无需明确使其可见.明确地执行此操作可使两个窗口均可见.

谢谢,
-Bhaskar
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


这篇关于Internet Explorer对象-navOpenInNewWindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆