CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 19

Threaded View

  1. #6
    Join Date
    Nov 2005
    Location
    NC, USA
    Posts
    99

    Re: Retrieving Arabic characters using GetWindowText?

    Quote Originally Posted by Ciralia View Post
    Another method I have tried is to use GetLine instead of GetWindowText, but I am unable to figure out how to get all of the lines from the RichEditCtrl into a single CString object. Here is the code I tried for that:

    Code:
    TCHAR tCharLine[4096];
    
    CRichEditCtrl* myEditCtrl = GetEdit( CtrlDefiniitions::COMPOSITION_EDIT );
    
    \\ This only gives me the first line from the RichEditCtrl, but I want all of the lines!
    int nBytesCopied = myEditCtrl->GetLine(0, tCharLine, sizeof(tCharline)/sizeof(tCharLine[0]));
    
    CString myString(tCharLine);
    The 2nd code snippet gives me the proper character output but only gives me the first line from the RichEditCtrl . Any ideas/suggestions?
    You have to use a loop and accumulate the lines one at a time. Here's what works for me:
    Code:
        CString text = "";
    
        int lines = m_cEdit.GetLineCount();
        for ( int i = 0; i < lines; i++ )
        {
            CString strText = "";
            int inx = m_cEdit.LineIndex(i);
            int len = max(m_cEdit.LineLength(inx), 4);
    
            m_cEdit.GetLine(inx, strText.GetBufferSetLength(len + 1), len);
            strText.SetAt(len, _T('\0')); // null terminate
            strText.ReleaseBuffer();
    
            text += strText + _T("\n");
        }
    
        // "text" now contains all lines from the CRichEditCtrl.
    Last edited by yooper; May 2nd, 2018 at 12:09 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured