简体   繁体   English

用.NetStandard打开定制的外部web浏览器

[英]Open customized external web browser with .NetStandard

We need to be able to open a web browser from within our application (.NetStandard 2.0).我们需要能够从我们的应用程序 (.NetStandard 2.0) 中打开 web 浏览器。 The browser should be opened as an external application, the requirement does not call for the browser to be embedded in our application, thus using the WebBroswer control is not an option.浏览器应该作为外部应用程序打开,要求不要求将浏览器嵌入到我们的应用程序中,因此不能使用 WebBroswer 控件。 We need to be able to specify the following options:我们需要能够指定以下选项:

  • Height of the browser浏览器高度
  • Width of the browser浏览器的宽度
  • Top position顶部 position
  • Left position离开 position
  • Addressbar enabled or disabled地址栏启用或禁用
  • Menubar enabled or disabled菜单栏启用或禁用
  • Statusbar enabled or disabled状态栏启用或禁用
  • Toolbar enabled or disabled启用或禁用工具栏

We initially thought that using the Process class would work, but it doesn't seem that these options can be specified with the Process class. Any articles or recommendations as to how we can achieve this would be greatly appreciated!我们最初认为使用流程 class 会起作用,但似乎无法使用流程 class 指定这些选项。任何关于我们如何实现这一点的文章或建议将不胜感激!

You could consider creating a Windows Form application or WPF application , then use the WebBrowser control to display the web page.您可以考虑创建一个 Windows Form 应用程序或WPF 应用程序,然后使用WebBrowser 控件显示 web 页面。

More detail information about using WebBrowser control, please check the following links:有关使用 WebBrowser 控件的更多详细信息,请查看以下链接:

WebBrowser Control Overview WebBrowser 控件概述

How to: Add Web Browser Capabilities to a Windows Forms Application 如何:将 Web 浏览器功能添加到 Windows Forms 应用程序

How to show address bar in WebBrowser control 如何在 WebBrowser 控件中显示地址栏

WebBrowser Control In WPF WebBrowser 控件在 WPF

Try to use the Inte.netExplorer object to control an instance of Windows Inte.net Explorer.尝试使用Inte.netExplorer object来控制 Windows Inte.net Explorer 的一个实例。

First, right click the application Reference and select Add Reference option, then in the COM tab, checked the Microsoft Inte.net Controls and click OK to add reference.首先,右键单击应用程序引用和 select添加引用选项,然后在COM选项卡中,选中Microsoft Inte.net 控件并单击确定添加引用。

在此处输入图像描述

Then, refer to the following code to use Inte.netExplorer object:然后,参考以下代码使用Inte.netExplorer object:

 SHDocVw.Inte.netExplorer ie = new SHDocVw.Inte.netExplorer(); ie.Navigate("http://www.bing.com"); ie.ToolBar = 0; //hide or display the toolbar. ie.AddressBar = false; //hide or display the AddressBar. ie.Left = 200; ie.Height = 800; ie.Width = 500; ie.StatusBar = false; // hide or display the statusBar. ie.Visible = true; //display IE browser.

More detail information about the properties, please check the IWebBrowser2 interface .有关属性的更多详细信息,请查看IWebBrowser2 接口

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

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