简体   繁体   English

Windows窗体隐藏的Web浏览器控件不会将IE窗口置于前台

[英]Windows form hidden web browser control does not bring the IE window to foreground

I have created add in for Outlook 2013. It has got a hidden web browser control within it. 我为Outlook 2013创建了加载项。其中包含一个隐藏的Web浏览器控件。 On button click Web browser loads the speciified data in Internet Explorer window. 单击按钮后,Web浏览器将在Internet Explorer窗口中加载指定的数据。 Content is loading but the IE window does not come to foreground and my outlook will continue be in focus. 内容正在加载,但是IE窗口没有出现,我的前景将继续成为焦点。 IE keeps blinking at the task bar. IE在任务栏上不断闪烁。

I want the IE window be in foreground. 我希望IE窗口处于前台。

If you want to show a Windows Form on top of Outlook window you need to specify the parent window handle. 如果要在Outlook窗口顶部显示Windows窗体,则需要指定父窗口句柄。 In your case it will be the explorer window handle. 在您的情况下,它将是资源管理器窗口句柄。 To get the handle you need to cast an instance of the Explorer class to the IOleWindow interface which provides the GetWindow method. 要获取该句柄,您需要将Explorer类的实例强制转换为提供GetWindow方法的IOleWindow接口。

The Show or ShowDialog methods of the System.Windows.Form class accepts an instance of the IWin32Window inteface which represents the handle of the parent window. System.Windows.Form类的Show或ShowDialog方法接受IWin32Window接口的实例,该实例表示父窗口的句柄。 Thus, your window will be shown on top of the parent one. 因此,您的窗口将显示在父窗口的顶部。

"Want to launch IE outside the outlook window. – " “想在前景窗口之外启动IE。–”

In that case use - https://msdn.microsoft.com/en-us/library/System.Diagnostics.Process.Start(v=vs.110).aspx 在这种情况下,请使用-https://msdn.microsoft.com/zh-CN/library/System.Diagnostics.Process.Start(v=vs.110).aspx

Process.Start(" http://URL "); Process.Start(“ http:// URL ”);

This will launch the default browser and navigate to the URL specified. 这将启动默认浏览器并导航到指定的URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM