MasterDucky
November 5th, 2009, 12:23 PM
Hello!
Im trying to use EM_GETLINE with vector<char> instead of a dynamic char array.
Its working with some minor bugs:
- if i type only one letter i get one garbage character
- there are some garbage at the end of the lines sometimes
Its maybe the vector functions that i dont use right.
Any suggestions highly appreciated.
case GetText:
{
int iCount, i;
WORD iLength, iOffset;
string buffer;
vector<char> vLines;
//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);
vLines.clear();
vLines.resize( iLength + sizeof(WORD)+1 );
CopyMemory(&vLines[0], &iLength, sizeof(WORD)+1);
SendMessage(hWin_2, EM_GETLINE, i, (LPARAM)&vLines[0]);
vLines.push_back( '\0' ); //do i need this?
SendMessage(hWin_1, LB_INSERTSTRING, -1, (LPARAM)&vLines[0]);
}
Im trying to use EM_GETLINE with vector<char> instead of a dynamic char array.
Its working with some minor bugs:
- if i type only one letter i get one garbage character
- there are some garbage at the end of the lines sometimes
Its maybe the vector functions that i dont use right.
Any suggestions highly appreciated.
case GetText:
{
int iCount, i;
WORD iLength, iOffset;
string buffer;
vector<char> vLines;
//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);
vLines.clear();
vLines.resize( iLength + sizeof(WORD)+1 );
CopyMemory(&vLines[0], &iLength, sizeof(WORD)+1);
SendMessage(hWin_2, EM_GETLINE, i, (LPARAM)&vLines[0]);
vLines.push_back( '\0' ); //do i need this?
SendMessage(hWin_1, LB_INSERTSTRING, -1, (LPARAM)&vLines[0]);
}