MasterDucky
November 5th, 2009, 09:03 AM
Hello!
Im trying to use EM_GETLINE with a c++ string instead of a dynamic char array.
It appears to function though i have some garbage sometimes at the end of the lines.
I cant see what am i doing wrong.
case GetText:
{
int iCount, i;
WORD iLength, iOffset;
string strLines;
//Get Number of Lines in Edit Field
iCount = SendMessage(hWin_2, EM_GETLINECOUNT, 0, 0);
if(!iCount) return 0;
for(i=0; i<iCount; i++)
{
iOffset = SendMessage(hWin_2, EM_LINEINDEX, i, 0);
iLength = (WORD)SendMessage(hWin_2, EM_LINELENGTH, iOffset, 0);
strLines = "";
strLines.resize(iLength + sizeof(WORD) + 1);
CopyMemory(&strLines[0], &iLength, sizeof(WORD)+1);
strLines += '\0';
SendMessage(hWin_2, EM_GETLINE, i, (LPARAM)&strLines[0]);
strLines += '\0';
SendMessage(hWin_1, LB_INSERTSTRING, -1, (LPARAM)&strLines[0]);
}
I can post the whole code if its not enough but the error must come from here because with a dynamic char array i dont have this problem. Thanks!
Im trying to use EM_GETLINE with a c++ string instead of a dynamic char array.
It appears to function though i have some garbage sometimes at the end of the lines.
I cant see what am i doing wrong.
case GetText:
{
int iCount, i;
WORD iLength, iOffset;
string strLines;
//Get Number of Lines in Edit Field
iCount = SendMessage(hWin_2, EM_GETLINECOUNT, 0, 0);
if(!iCount) return 0;
for(i=0; i<iCount; i++)
{
iOffset = SendMessage(hWin_2, EM_LINEINDEX, i, 0);
iLength = (WORD)SendMessage(hWin_2, EM_LINELENGTH, iOffset, 0);
strLines = "";
strLines.resize(iLength + sizeof(WORD) + 1);
CopyMemory(&strLines[0], &iLength, sizeof(WORD)+1);
strLines += '\0';
SendMessage(hWin_2, EM_GETLINE, i, (LPARAM)&strLines[0]);
strLines += '\0';
SendMessage(hWin_1, LB_INSERTSTRING, -1, (LPARAM)&strLines[0]);
}
I can post the whole code if its not enough but the error must come from here because with a dynamic char array i dont have this problem. Thanks!