C# 是否可以像 WebView 一样在 Windows 窗体中嵌入 Gecko 或 Webkit?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26147/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to Embed Gecko or Webkit in a Windows Form just like a WebView?
提问by Martin Marconcini
I'd love to know if there is such a thing as a Gecko.NET ;) I mean, just like we can embed a WebView and that is an "instance" of IE7 inside any Windows Forms application (and tell it to navigateto(fancy_url);
). I'd love to use Firefox or WebKit.
我很想知道是否有 Gecko.NET 之类的东西;) 我的意思是,就像我们可以嵌入一个 WebView 一样,这是任何 Windows 窗体应用程序中 IE7 的“实例”(并告诉它navigateto(fancy_url);
)。我喜欢使用 Firefox 或 WebKit。
Anybody tried this?
有人试过这个吗?
UPDATE: Please bear in mind that although it is possible to embed Gecko using the mentioned controls, it is still impossible to printwhile using Gecko.
更新:请记住,虽然可以使用上述控件嵌入 Gecko,但在使用 Gecko 时仍然无法打印。
UPDATE March 2010: It's still not possible to print natively using GeckoFX, however a couple of methods exist that maybe enough, depending upon what you're trying to do. See: http://geckofx.org/viewtopic.php?id=796for more information.
2010 年 3 月更新:仍然无法使用 GeckoFX 进行本机打印,但是存在几种方法可能就足够了,具体取决于您要执行的操作。请参阅:http: //geckofx.org/viewtopic.php?id=796了解更多信息。
UPDATE October 2013: I am no longer doing Windows development so I have no interest in this, but seems like the development of Gecko can be found here: https://bitbucket.org/geckofxand it seems to be recently updated. Leaving this here for future Windows devs ;)
2013 年 10 月更新:我不再进行 Windows 开发,所以我对此不感兴趣,但似乎可以在此处找到 Gecko 的开发:https: //bitbucket.org/geckofx,它似乎最近已更新。留在这里供未来的 Windows 开发人员使用;)
UPDATE January 2017: I have gotten an email from a company called TeamDev. They created a Chromium-based .NET browser component called "DotNetBrowser" which can be used to display modern web pages in Windows Forms applications.
2017 年 1 月更新:我收到了来自一家名为TeamDev的公司的电子邮件。他们创建了一个名为“DotNetBrowser”的基于 Chromium 的 .NET 浏览器组件,可用于在 Windows 窗体应用程序中显示现代网页。
To quote the email directly:
直接引用电子邮件:
Here are some details about the component, which might be helpful:
以下是有关该组件的一些详细信息,可能会有所帮助:
- DotNetBrowser is based on Chromium, thus supporting HTML5, CSS3, JS and the latest web standards. The underlying Chromium version of the library is regularly updated.
- The component is suitable for WPF as well as Windows Forms desktop applications, and works both for C# and VB.NET.
- The library is licensed commercially, however free licences are provided for Open Source and academic projects.
- DotNetBrowser 基于 Chromium,因此支持 HTML5、CSS3、JS 和最新的 Web 标准。该库的底层 Chromium 版本会定期更新。
- 该组件适用于 WPF 以及 Windows 窗体桌面应用程序,并且适用于 C# 和 VB.NET。
- 该库已获得商业许可,但为开源和学术项目提供免费许可。
Disclaimer:I have not used this DotNetBrowser for I no longer do Windows Development but may be worth checking if you're looking for a solution to this.
免责声明:我没有使用这个 DotNetBrowser,因为我不再进行 Windows 开发,但如果您正在寻找解决方案,可能值得检查。
采纳答案by HS.
http://code.google.com/p/geckofx/
http://code.google.com/p/geckofx/
This is a nice .NET-wrapped version of Gecko
这是一个很好的 .NET 包装的 Gecko 版本
回答by TheSmurf
It certainly is possible. All you need to do is register the Mozilla ActiveX control (mozctlx.dll I believe), and you can drag it onto your form as any ActiveX control. The programming interface is similar (though not identical) to the IE one, and you can even use the Microsoft.MSHTML.dll managed library for control in some cases.
这当然是可能的。您需要做的就是注册 Mozilla ActiveX 控件(我相信是 mozctlx.dll),然后您可以将它作为任何 ActiveX 控件拖到您的表单上。编程界面与 IE 相似(虽然不完全相同),在某些情况下,您甚至可以使用 Microsoft.MSHTML.dll 托管库进行控制。
I believe this is packaged with Firefox. If not, you can get just the embeddable bits from Mozilla as well. Just do a Google search for Mozilla ActiveX control or Mozilla Embedding C# and that should take you down the right path.
我相信这是与 Firefox 一起打包的。如果没有,您也可以从 Mozilla 获得可嵌入的位。只需在 Google 上搜索 Mozilla ActiveX 控件或 Mozilla Embedding C#,您就会找到正确的道路。
回答by wfarr
Additionally, if you find yourself using Gtk instead of Windows.Forms, there is a tarball of webkit-sharp available that allows for easy embedding of WebViews into Gtk# applications.
此外,如果您发现自己使用 Gtk 而不是 Windows.Forms,则可以使用 webkit-sharp 的 tarball,它允许将 WebViews 轻松嵌入到 Gtk# 应用程序中。
回答by TheSmurf
@Martin: Yes, the Adam Locke version is outdated. But that's because a separate distribution is not necessary. It's built with the rest of the Mozilla codebase now.
@Martin:是的,Adam Locke 版本已经过时了。但那是因为不需要单独的分发。它现在是用 Mozilla 代码库的其余部分构建的。
If you download Prism (ie XulRunner), that will give you a base that you can customize to your needs, and this includes the most recent version of the control (in the \Prism\xulrunner directory, you'll find mozctlx.dll).
如果您下载 Prism(即 XulRunner),它将为您提供一个可以根据需要自定义的基础,其中包括最新版本的控件(在 \Prism\xulrunner 目录中,您将找到 mozctlx.dll) .
@Greg: Actually, it is an ActiveX control. Incidentally, all ActiveX controls areCOM controls. ActiveX is built on COM.
@Greg:实际上,它是一个 ActiveX 控件。顺便说一下,所有的 ActiveX 控件都是COM 控件。ActiveX 建立在 COM 之上。
回答by garthy
I Belive "Gecko FX"[1] is the thing you need.
我相信“Gecko FX”[1] 是您所需要的。
To Quote from the web site
从网站报价
""" GeckoFX is a Windows Forms control written in clean, commented C# that embeds the Mozilla Gecko browser control in any Windows Forms Application. It also contains a simple class model providing access to the HTML and CSS DOM. """
""" GeckoFX 是一个用干净的注释 C# 编写的 Windows 窗体控件,它将 Mozilla Gecko 浏览器控件嵌入到任何 Windows 窗体应用程序中。它还包含一个简单的类模型,提供对 HTML 和 CSS DOM 的访问。"""
1) I can't post a link as "new users aren't allowed to add hyperlinks" Search for "geckofx" on google code.
1)我无法发布链接,因为“不允许新用户添加超链接”在谷歌代码上搜索“geckofx”。
回答by Scott
GeckoFX is no longer being updated. The alternative is the MozNet XulRunner wrapperby Se7en Soft. MozNet has a ton of features that GeckoFX doesn't and is being actively updated and maintained.
GeckoFX 不再更新。另一种选择是Se7en Soft的MozNet XulRunner 包装器。MozNet 拥有大量 GeckoFX 没有的功能,并且正在积极更新和维护。
回答by Scott
I'd just like to point out, to all looking to embed Gecko into their applications, that the GeckoFX project appears to have been abandoned by its creators (Skybound Software). MozNET, while previously based on GeckoFX, sorta' picked up the ball and ran with it. It has the full ability to print, do print previews and allows you to set it all up via the native Windows print dialog, even - and a whole lot more.
我只想指出,对于所有希望将 Gecko 嵌入其应用程序的人,GeckoFX 项目似乎已被其创建者(Skybound Software)放弃。MozNET,虽然之前基于 GeckoFX,但有点“捡起球并带着它跑”。它具有完整的打印、打印预览功能,并允许您通过本机 Windows 打印对话框进行设置,甚至还有更多功能。
回答by George
OpenWebKitSharp is a wrapper arount the WebKit engine (nightly) and is very advanced. Take a look at here (OpenWebKitSharp section): http://code.google.com/p/open-webkit-sharp/
OpenWebKitSharp 是围绕 WebKit 引擎(每晚)的包装器,并且非常先进。看看这里(OpenWebKitSharp 部分):http: //code.google.com/p/open-webkit-sharp/
回答by John Hatton
As of October 30, 2011, there is new information to add since the time of the previous posts. Specifically, while Skybound stopped maintaining their version, there is at least one actively maintained, free, open-source fork available.
截至 2011 年 10 月 30 日,自上次发布以来,有新信息要添加。具体来说,虽然 Skybound 停止维护他们的版本,但至少有一个积极维护的、免费的、开源的分支可用。
I'm using Hindle's forkat BitBucket, which, by virtue of his tool which parses XpCom idls and creates c# wrappers, is rapidly updated with support for each new version of Firefox/Gecko.
我在 BitBucket 上使用Hindle 的 fork,凭借他的工具解析 XpCom idls 并创建 c# 包装器,它可以快速更新以支持每个新版本的 Firefox/Gecko。
See this postfor an overview of other choices.
有关其他选择的概述,请参阅此帖子。
回答by daniel.herken
Update 2016:
2016 年更新:
A .Net component which can be used to integrate the Firefox engineinto your .Net application. This is based on Geckofxbut unlike the current version of Geckofx this will work with a normal release build of Firefox. To use Geckofx you will need to build Firefox yourself. Again commercial supportis available but the component itself is fully open source.
一个 .Net 组件,可用于将Firefox 引擎集成到您的 .Net 应用程序中。这是基于Geckofx 的,但与当前版本的 Geckofx 不同,这将适用于 Firefox 的正常发布版本。要使用 Geckofx,您需要自己构建 Firefox。再次提供商业支持,但组件本身是完全开源的。
(Full disclosure: I work for this company so take everything I say with a grain of salt)
(完全披露:我在这家公司工作,所以对我所说的一切持保留态度)