Windows 浏览器控件与 CDHtmlDialog 和 CHtmlView
我想知道以下控制和类之间的区别。
Windows 浏览器控件与 CDHtmlDialog
和 CHtmlView
。
可见这些东西是用来在UI中添加html内容的 基于Windows的应用程序。
但当我们在互联网上搜索时,常常会与这些东西混淆。
如果有人解释一下这些控件和类的可用性,那就太好了。
I wanted to know the difference among following control and classes.
Windows Browser Control Vs CDHtmlDialog
and CHtmlView
.
It is visible that these things are used to add html content in UI for
windows based application.
But when we search in internet one will often confused with these things.
It would be good if some explain the usability of these Control and Classes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Web 浏览器控件是一个 Windows ActiveX 控件,Internet Explorer 本身可能使用它来显示 HTML 内容。至少,Web 浏览器控件和 Internet Explorer 使用相同的实现来呈现 HTML。
CHtmlView
是托管所述 ActiveX 控件的 MFC -CView
派生类。CHtmlDialog
是一个 MFC -CDialog
- 派生类,执行相同的操作。它们是单独的类,因为不幸的是 MFC 在对话框、视图和窗口之间存在“巨大的差距”。
我没有大量使用过这两个 MFC 类,但据我了解,它们本身并没有添加任何功能。您也可以像普通 ActiveX 一样托管 Web 浏览器控件,并使用
GetControlUnknown
获取IWebBrowser
接口。根据我的经验,最大的问题是 DOM 只能在
DocumentComplete
之后访问,并且在消息循环不泵送之前该事件不会触发。这使得一些操作变得相当痛苦,我最终使用了一个自定义接口来排队修改,直到 DOM 可用。PS Windows 现在提供基于 Edge 的 WebView2 - ActiveX 控件,作为足够且强大的替代品。请参阅 https://learn.microsoft.com/en-us/microsoft-边缘/webview2/
The Web Browser Control is a Windows ActiveX control that is probably used by Internet Explorer itself to display HTML contents. At the very least, Web Browser Control and Internet Explorer use the same implementation for rendering HTML.
CHtmlView
is a MFC -CView
-derived class hosting said ActiveX control.CHtmlDialog
is a MFC -CDialog
- derived class doing the same.They are separate classes because unfortunately MFC has a "huge gap" between dialogs, views and windows.
I haven't worked significantly with either MFC class but in my understanding they don't add any functionality by themselves. You can as well host the web browser control like a normal ActiveX and use
GetControlUnknown
to acquireIWebBrowser
interface.The biggest problem in my experience is that DOM is only accessible after
DocumentComplete
, and that event won't fire before the message loop doesn't pump. This makes some operations rather painful I ended up with a custom interface queuing modifications until DOM is available.P.S. Windows now offers the WebView2 - ActiveX control, based on Edge, as a sufficient and powerful replacement. see https://learn.microsoft.com/en-us/microsoft-edge/webview2/