dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: Retrieving Arabic characters using GetWindowText?

  1. #16
    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.

  2. #17
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,249

    Re: Retrieving Arabic characters using GetWindowText?

    Dear yooper,

    are you sure the OP still needs some help in solving the problem he/she had more than seven years back?
    Victor Nijegorodov

  3. #18
    Join Date
    Nov 2005
    Location
    NC, USA
    Posts
    99

    Re: Retrieving Arabic characters using GetWindowText?

    Whether the OP does or someone else who stumbles onto this thread, what's wrong with posting my soluction?

  4. #19
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,249

    Re: Retrieving Arabic characters using GetWindowText?

    Quote Originally Posted by yooper View Post
    Whether the OP does or someone else who stumbles onto this thread, what's wrong with posting my soluction?
    Nothing wrong except it is not actual.
    And you could just post the link to MSDN example rather than reinvent the wheel...
    Victor Nijegorodov

Page 2 of 2 FirstFirst 12

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)