如何在基于对话框的应用程序上使用CHTMLView类。
问题描述:
任何人都可以告诉我如何在基于对话框的应用程序中使用CHTMLView类。我想在MFC对话框中显示HTML文档的预览。
提前感谢。
Hi,
Can anyone tell me how to use CHTMLView class in dialog based application. I want to show preview of the HTML document on the MFC dialog.
Thanks in advance.
答
MFC View类确实需要完整的Document / View架构,所以你需要的是封装在CHTMLView类中的HTML控件。
有几篇文章这里涵盖了你需要的东西 -
http://www.codeproject。 com / KB / miscctrl / simplebrowserformfc.aspx [ ^ ]和 http://www.codeproject.com/KB/MFC/dhtmldialog.aspx [ ^ ]例如。
The MFC View classes really need the full Document/View architecture, so what you need is the HTML control that is encapsulated in the CHTMLView class.
There are several articles here that cover the sort of thing you need -
http://www.codeproject.com/KB/miscctrl/simplebrowserformfc.aspx[^] and http://www.codeproject.com/KB/MFC/dhtmldialog.aspx[^] for example.
你不需要doc / view架构,这是一个简单的解决方案。
1)在对话框头文件中添加:
You dont need doc/view architecture, here is a simple solution.
1) In your dialog header file add:
CDHtmlDialog m_HtmCtrl;
2)在对话框上放置一个图片控件。
3)在你的对话框OnInit函数中添加:
2) Place a picture control on your dialog.
3) In your dialog OnInit function add:
VERIFY(m_HtmCtrl.SubclassDlgItem(IDC_PICTURE_CTRL, this));
m_HtmCtrl.OnInitDialog();
m_HtmCtrl.Navigate(_T("SomePage.htm"));
4)您可能已经拥有此功能,但请确保以下内容包含在您的stdafx文件中:
4) You probably already have this but make sure the following include is in your stdafx file:
#include <afxdhtml.h>