![]() |
CRichEditCtrl - RTF - BIG - Help |
Post Reply ![]() |
Author | |
barobax ![]() Senior Member ![]() Joined: 07 May 2008 Status: Offline Points: 117 |
![]() ![]() ![]() ![]() ![]() Posted: 18 September 2008 at 2:46pm |
Hi,
I have a problem with CRichEditCtrl in MFC. I want to get char under mouse cursor.I use charFrompos but when I set a RTF format to RE this will not work. int nPos = CRichEditCtrl::CharFromPos(point); int nLine = HIWORD(nPos);// it's zero always when I set an RTF string. RTF replace \par with \n int nIndex = LOWORD(nPos); CString sText; CRichEditCtrl::GetWindowText(sText); char pChar1 = sText[nIndex]; //it's not char under mouse cursor. char pChar2 = m_RTFText[nIndex]; //it's not char under mouse cursor too. The codejock have a subclass from CRichEditCtrl ?!? or any other help at your experience ?!? Thanks, Best Regards, |
|
![]() |
|
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() |
Not sure, but beware of "\r\n" for linebreaks. CharFromPos is not dependent of the underlying RTF.
|
|
![]() |
|
barobax ![]() Senior Member ![]() Joined: 07 May 2008 Status: Offline Points: 117 |
![]() ![]() ![]() ![]() ![]() |
Hi,
Thank you very much for your answer but my problem not solved |
|
![]() |
|
barobax ![]() Senior Member ![]() Joined: 07 May 2008 Status: Offline Points: 117 |
![]() ![]() ![]() ![]() ![]() |
Hi,This is my Method.
EDITSTREAM EnEnWriter::GetRTF() { CTime time; int sec1 = time.GetSecond(); m_sRTF = L"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}}{\\colortbl ;\\red0\\green0\\blue128;\\red0\\green0\\blue255;\\red0\\green128\\blue0;\\red128\\green0\\blue0;}{\\*\\generator Msftedit 5.41.21.2508;}\\viewkind4\\uc1\\pard\\f0\\fs20" + m_sRTF; m_sRTF.Replace(L"\r\n", L"\\par"); // If this line is commented, charfrompos work correctly else wrong. int nLength = m_sRTF.GetLength(); /////////////////////////Etymology/////////////////////////// int nIndex = 0; nIndex = m_sRTF.Find(L"Etymology", nIndex); while (nIndex != -1) { m_sRTF.Insert(nIndex, L"\\cf1"); nIndex += 13; m_sRTF.Insert(nIndex, L"\\cf0"); nIndex = m_sRTF.Find(L"Etymology", nIndex); } ////////////////////////Functions//////////////////////////// nIndex = 0; nIndex = m_sRTF.Find(L"transitive verb", nIndex); while (nIndex != -1) { m_sRTF.Insert(nIndex, L"\\cf2"); nIndex += 19; m_sRTF.Insert(nIndex, L"\\cf0"); nIndex = m_sRTF.Find(L"transitive verb", nIndex); } ////////////////////////Comments//////////////////////////// nIndex = 0; nIndex = m_sRTF.Find(L"<", nIndex); while (nIndex != -1) { m_sRTF.Insert(nIndex, L"\\cf3"); nIndex = m_sRTF.Find(L">", nIndex);; if (nIndex != -1) { m_sRTF.Insert(nIndex + 1, L"\\cf0"); nIndex = m_sRTF.Find(L"<", nIndex); } } int final = (time.GetSecond() - sec1); EDITSTREAM pStream; pStream.dwCookie = (DWORD)&m_sRTF; // Pass a pointer to the CString to the callback function pStream.pfnCallback = StreamInCallback; // Specify the pointer to the callback function return pStream; } |
|
(Farsi IS WRONG you must say [PARSI])
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |