Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CRichEditCtrl - RTF - BIG - Help
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CRichEditCtrl - RTF - BIG - Help

 Post Reply Post Reply
Author
Message
barobax View Drop Down
Senior Member
Senior Member


Joined: 07 May 2008
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote barobax Quote  Post ReplyReply Direct Link To This Post Topic: CRichEditCtrl - RTF - BIG - Help
    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,
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 19 September 2008 at 5:55am
Not sure, but beware of "\r\n" for linebreaks. CharFromPos is not dependent of the underlying RTF.
Back to Top
barobax View Drop Down
Senior Member
Senior Member


Joined: 07 May 2008
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote barobax Quote  Post ReplyReply Direct Link To This Post Posted: 19 September 2008 at 9:48am
Hi,
Thank you very much for your answer but my problem not solved
Back to Top
barobax View Drop Down
Senior Member
Senior Member


Joined: 07 May 2008
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote barobax Quote  Post ReplyReply Direct Link To This Post Posted: 20 September 2008 at 4:34pm
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])
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.031 seconds.