Click here to Skip to main content
15,891,946 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

You dont need doc/view architecture, here is a simple solution.

1) In your dialog header file add:

CDHtmlDialog	m_HtmCtrl;


2) Place a picture control on your dialog.

3) In your dialog OnInit function add:

C++
VERIFY(m_HtmCtrl.SubclassDlgItem(IDC_PICTURE_CTRL, this));
m_HtmCtrl.OnInitDialog();
m_HtmCtrl.Navigate(_T("SomePage.htm"));


4) You probably already have this but make sure the following include is in your stdafx file:

#include <afxdhtml.h>
 
Share this answer
 
v2
Comments
TSchind 12-Feb-21 11:01am    
Great, still works in VS2019
JJMatthews 7-Apr-21 14:45pm    
thats cool to know, thanks for the info brother.
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.
 
Share this answer
 
Comments
aamswe 19-Oct-10 2:04am    
Thanks,
It's really very usefull for me....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900