Hi Friends,
I have created a
CRichEditCtrl
object and set its text mode as RTF
using
m_oRichEditCtrl.SetTextMode(TM_RICHTEXT);
after that i set rtf text. now i want to re-position rich edit such that it fits to its content.
Is there any method which give me correct rect which fit the rtf text?
m_oRichEditCtrl.Create(WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_READONLY,CRect(0,0,0,0),this,12568);
m_oRichEditCtrl.SetTextMode(TM_RICHTEXT);
CString strRTFText =L"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\ul\b\i\f0\fs22 Hello\ulnone\b0\i0\par
}" ;
CString strTmp2;
int il = WideCharToMultiByte(CP_ACP,0, (LPCWSTR)strRTFText,strRTFText.GetLength(), (LPSTR)strTmp2.GetBufferSetLength(wcslen(strRTFText)), wcslen(strRTFText),NULL,NULL);
strTmp2.ReleaseBufferSetLength(il);
int iTextMode = m_oRichEditCtrl.SetTextMode(TM_RICHTEXT);
m_oRichEditCtrl.SetWindowText(strTmp2);
CDC * dc = m_oRichEditCtrl.GetDC();
CString strRichEdit;
m_oRichEditCtrl.GetWindowText(strRichEdit);
CRect rcText(0,0,m_uWidth,0);
dc->DrawText(strRichEdit,&rcText,DT_CALCRECT|DT_EDITCONTROL);