VS2010中怎样添加 Forms.WebBrowser ?

wugamp 2016-08-12 09:01:33
想用 VS2010 显示 MHT 文件,为此需要用到 System.Windows.Forms.WebBrowser。
但是如果直接从 tool box 拖到界面上的话,得到是 System.Window.Controls.WebBrowser。
请问怎样才能添加 Forms.WebBrowser 呢?
...全文
161 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wugamp 2016-08-15
  • 打赏
  • 举报
回复
多谢你的启发,搞定了! 原来应该先建立一个普通的 form,把webBrowser 嵌进去。
  • 打赏
  • 举报
回复
引用 6 楼 wugamp 的回复:
[quote=引用 5 楼 zjq9931 的回复:] [quote=引用 4 楼 wugamp 的回复:] 刚才尝试了这个办法: 一、在项目中 add new item,选择 form,于是多了一个 form1 类 二、在 form1.cs 中,手工改成: public partial class Form1 : WebBrowser。至此,编译通过。下面的问题就是如何显示之了。 三、在项目里声明一个 form1对象: public partial class MainWindow : Window { AsyncUdpClient MainAsyncUdpClient = null; private bool reverse = false; public MainWindow() { InitializeComponent(); } Form1 g_f; 四、在按钮里,加上 g_f.Show()。 编译通过,运行无错,但 g_f 不出现。
直接改肯定是无法显示的,有没有指定g_f的网页呢?指定好了应当就可以了。[/quote] 指定了啊,是本地的 MHT 文件: private void button1_Click(object sender, RoutedEventArgs e) { g_f = new Form1(); g_f.Width = 500; g_f.Height = 500; g_f.Navigate(@"d:\w\froPC.mht"); g_f.Show(); } 点击按钮后,看到鼠标停滞了一会,应该是读入了 MHT,没报错,但不显示。[/quote] 我不确定C#是怎么搞得。 MFC不是这样做的。。。 MFC里面需要有两个:一个模板窗口,和一个HTML。 不知道C#是否需要模板窗口(就是HTML在哪个窗口里面显示),我想应当是需要的。 否则就是hta文件打开的那种样子了。
wugamp 2016-08-12
  • 打赏
  • 举报
回复
引用 5 楼 zjq9931 的回复:
[quote=引用 4 楼 wugamp 的回复:] 刚才尝试了这个办法: 一、在项目中 add new item,选择 form,于是多了一个 form1 类 二、在 form1.cs 中,手工改成: public partial class Form1 : WebBrowser。至此,编译通过。下面的问题就是如何显示之了。 三、在项目里声明一个 form1对象: public partial class MainWindow : Window { AsyncUdpClient MainAsyncUdpClient = null; private bool reverse = false; public MainWindow() { InitializeComponent(); } Form1 g_f; 四、在按钮里,加上 g_f.Show()。 编译通过,运行无错,但 g_f 不出现。
直接改肯定是无法显示的,有没有指定g_f的网页呢?指定好了应当就可以了。[/quote] 指定了啊,是本地的 MHT 文件: private void button1_Click(object sender, RoutedEventArgs e) { g_f = new Form1(); g_f.Width = 500; g_f.Height = 500; g_f.Navigate(@"d:\w\froPC.mht"); g_f.Show(); } 点击按钮后,看到鼠标停滞了一会,应该是读入了 MHT,没报错,但不显示。
  • 打赏
  • 举报
回复
引用 4 楼 wugamp 的回复:
刚才尝试了这个办法: 一、在项目中 add new item,选择 form,于是多了一个 form1 类 二、在 form1.cs 中,手工改成: public partial class Form1 : WebBrowser。至此,编译通过。下面的问题就是如何显示之了。 三、在项目里声明一个 form1对象: public partial class MainWindow : Window { AsyncUdpClient MainAsyncUdpClient = null; private bool reverse = false; public MainWindow() { InitializeComponent(); } Form1 g_f; 四、在按钮里,加上 g_f.Show()。 编译通过,运行无错,但 g_f 不出现。
直接改肯定是无法显示的,有没有指定g_f的网页呢?指定好了应当就可以了。
wugamp 2016-08-12
  • 打赏
  • 举报
回复
刚才尝试了这个办法: 一、在项目中 add new item,选择 form,于是多了一个 form1 类 二、在 form1.cs 中,手工改成: public partial class Form1 : WebBrowser。至此,编译通过。下面的问题就是如何显示之了。 三、在项目里声明一个 form1对象: public partial class MainWindow : Window { AsyncUdpClient MainAsyncUdpClient = null; private bool reverse = false; public MainWindow() { InitializeComponent(); } Form1 g_f; 四、在按钮里,加上 g_f.Show()。 编译通过,运行无错,但 g_f 不出现。
  • 打赏
  • 举报
回复
引用 2 楼 wugamp 的回复:
但是我是要修改一个现有的程序,而不是重新创建程序啊! 当然我也试过 add new item, 里面允许加一个 windows.form,问题是怎么才能指定此为 webBrowser 呢?
你是用的C# 如果是MFC,不是很复杂,有CDHtmlDialog类。 从这个类里面派生就好了。 C#没做过,抱歉。。。
wugamp 2016-08-12
  • 打赏
  • 举报
回复
但是我是要修改一个现有的程序,而不是重新创建程序啊! 当然我也试过 add new item, 里面允许加一个 windows.form,问题是怎么才能指定此为 webBrowser 呢?
  • 打赏
  • 举报
回复
在创建工程的第2步就有啊,使用基于HTML的对话框。这个就是。
Chrome based Browser Engine for .NET EO.WebBrowser is a web browser engine based on Google's Chromium project but with native .NET programming interface --- don't worry, it's not a wrapper around the Chrome browser installed on your machine. In fact EO.WebBrowser has the whole browser engine embedded inside a single .NET DLL. In another word, it has zero external dependency. Just reference and use. Why use EO.WebBrowser? • Based on Google's Chrome Project EO.WebBrowser uses the same core Google's Chrome and Apple Safari uses. It does not rely on IE. The engine is much faster and safer. • Zero External Dependency What if user updates/uninstall their browser? What if user disables JavaScript in Internet Explorer's settings dialog? These questions does not exist with EO.WebBrowser because everything is embedded inside our DLL files. • Native .NET components written in C# Because it's written in .NET, you can use it with any .NET based language/development tool. The same DLL works for both 32 bit and 64 bit environments; • Easy to use Programming Interface EO.WebBrowser offers core components that can be used in any Windows application, as well as wrapper controls for both Windows Forms applications and WPF applications; • Extensive Customization Options EO.WebBrowser offers extensive customization options that allow you to customize context menu, hot keys, JavaScript dialogs, file dialogs, focus and window control. Together these features allow you to seamlessly integrate the browser engine into your application; • .NET code -> JavaScript code Turn any web page into an integral part of your application -- both visually and programmatically. You can execute JavaScript code and access all the JavaScript objects directly from your .NET code. Access their properties or even call a JavaScript function are all different options available to you; • JavaScript code -> .NET code Things always go both ways --- and this is reflected in our programming interface as well. You can call JavaScript code from .NET code, and the other way around is also true --- you can call .NET code from your JavaScript code. This allows your Web page to seamlessly interact with the host application; • Custom Resource Handler Want to keep an eye on everything? Or want to keep everything to yourself? We got you covered. EO.WebBrowser offers ability to intercept and modify all requests that originate from the browser engine. For example, you can automatically deny all request sent to a specific host. It also offers you the ability to implement custom protocols or custom resource handlers. For example, you can implement a custom request handler to load images from your database instead of a Web server;

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧