////////////////////////////////////////////////////////////////////////////// // MFC Tip #3 -- Vision X Software -- http://www.visionx.com/mfcpro // Using a rich edit control in a dialog box // // This source code is provided for instructional purposes, and is released // to the public domain. No claim of ownership is made. Use it at your own // risk. No warranties are expressed or implied. The resulting program may // not be fully functional. No animals were used to test this code. ////////////////////////////////////////////////////////////////////////////// void CMyDialog::OnInitDialog() { // Get a pointer to the place holder control. CWnd *pCtl = GetDlgItem(IDC_RICH); // If you use an edit control as place // holder, you can grab its styles. DWORD dwStyles = GetWindowLong(pCtl->m_hWnd, GWL_STYLE); // Get the place holder's position in the dialog. CRect rect; pCtl->GetWindowRect(&rect); ScreenToClient(&rect); // Kill the place holder control. pCtl->DestroyWindow(); // Create a new rich edit control with the same // style flags, rectangle, and identifier. m_MyRichEditCtl.Create(dwStyles, &rect, this, IDC_RICH); }