MFC: CHtmlEditCtrl - simple HTML Editor
2013-01-28 23:45:39 Moscow time
Static control is needed to use CHtmlEditCtrl
class.
BOOL CSomeDlg::OnInitDialog()
{
...
// TODO: Add extra initialization here
CStatic wndStatic;
wndStatic.SubclassDlgItem(IDC_HTMLSTATIC, this);
CRect rect;
wndStatic.GetWindowRect(rect);
ScreenToClient(rect);
if (m_ctlEditHtml.Create(NULL, WS_CHILD | WS_VISIBLE, rect, this, IDC_HTMLSTATIC) != TRUE)
return FALSE;
return TRUE;
}
By the way, there is a bug with hiding the control: BUG: WebBrowser Control Destroyed When Hidden.
How to reproduce:
Consider the following code:
m_ctlEditHtml.ShowWindow(SW_HIDE);
m_ctlEditHtml.ShowWindow(SW_SHOW);
The application crashes.
Workaround:
::ShowWindow(m_ctlEditHtml.GetSafeHwnd(), SW_HIDE);
::ShowWindow(m_ctlEditHtml.GetSafeHwnd(), SW_SHOW);