Anyone has any experience on using CHtmlEditCtrl?
-
CHtmlEditCtrl is a new class introduced since MFC 7.0. It sounds like a great class, which can be used in dialogs for WYSIWYG html editing. But I have a big problem in using CHtmlEditCtrl::SetDocumentHTML after its creation:
BOOL CTestDlg::OnInitDialog() { CDialog::OnInitDialog(); CString str = "<html>My page<p>test</p></html>"; CHtmlEditCtrl* m_pHtmlEditor = new CHtmlEditCtrl(); m_pHtmlEditor ->Create("",0,CRect(10,10,200,200),this,IDC_HTMLEDITOR); // put some html code in it m_pHtmlEditor->SetDocumentHTML(str); return TRUE; }
Everything looks good, but when I run the app, the HTML code in "str" does not show up in the HTML Editor window :(( i.e., the html editor window is blank after the dialog appears on the screen. What's more "interesting" (and frustrating) is, if I put a MessageBox before m_pHtmlEditor->SetDocumentHTML(str); i.e., change the code to:BOOL CTestDlg::OnInitDialog() { CDialog::OnInitDialog(); CString str = "<html>My page<p>test</p></html>"; CHtmlEditCtrl* m_pHtmlEditor = new CHtmlEditCtrl(); m_pHtmlEditor ->Create("",0,CRect(10,10,200,200),this,IDC_HTMLEDITOR); **AfxMessageBox("test");** // put some html code in it m_pHtmlEditor->SetDocumentHTML(str); return TRUE; }
It then works! The HTML code in "str" is showing up in the HTML editor window. But I really don't need that MessageBox. Anybody has any idea? I am really stuck. I can provide a link to my test project if anyone needs it. Big thanks! :rose: -
CHtmlEditCtrl is a new class introduced since MFC 7.0. It sounds like a great class, which can be used in dialogs for WYSIWYG html editing. But I have a big problem in using CHtmlEditCtrl::SetDocumentHTML after its creation:
BOOL CTestDlg::OnInitDialog() { CDialog::OnInitDialog(); CString str = "<html>My page<p>test</p></html>"; CHtmlEditCtrl* m_pHtmlEditor = new CHtmlEditCtrl(); m_pHtmlEditor ->Create("",0,CRect(10,10,200,200),this,IDC_HTMLEDITOR); // put some html code in it m_pHtmlEditor->SetDocumentHTML(str); return TRUE; }
Everything looks good, but when I run the app, the HTML code in "str" does not show up in the HTML Editor window :(( i.e., the html editor window is blank after the dialog appears on the screen. What's more "interesting" (and frustrating) is, if I put a MessageBox before m_pHtmlEditor->SetDocumentHTML(str); i.e., change the code to:BOOL CTestDlg::OnInitDialog() { CDialog::OnInitDialog(); CString str = "<html>My page<p>test</p></html>"; CHtmlEditCtrl* m_pHtmlEditor = new CHtmlEditCtrl(); m_pHtmlEditor ->Create("",0,CRect(10,10,200,200),this,IDC_HTMLEDITOR); **AfxMessageBox("test");** // put some html code in it m_pHtmlEditor->SetDocumentHTML(str); return TRUE; }
It then works! The HTML code in "str" is showing up in the HTML editor window. But I really don't need that MessageBox. Anybody has any idea? I am really stuck. I can provide a link to my test project if anyone needs it. Big thanks! :rose:Did you find any solution for this problem??