-
May 2nd, 2018, 11:06 AM
#16
Re: Retrieving Arabic characters using GetWindowText?
Originally Posted by Ciralia
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.
-
May 2nd, 2018, 12:15 PM
#17
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
-
May 3rd, 2018, 11:53 AM
#18
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?
-
May 3rd, 2018, 12:49 PM
#19
Re: Retrieving Arabic characters using GetWindowText?
Originally Posted by yooper
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
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|