Have this function to read in user input from my edit box.. but it sometimes only reads in like 80-90% of a line.. what am I doing wrong..??!?
Code:
void EditBoxFileParser(HWND hwnd, HWND hEdit)
{
int iCount;
WORD iLength;
TCHAR **Lines;
//Get Number of Lines in Edit Field
iCount = SendMessage(hEdit, EM_GETLINECOUNT, 0, 0);
//If Editbox is empty, exit function
if(!iCount)
return;
Lines = new TCHAR*[iCount];
//Populate 2D array, Lines[LineIndex][LineText]
for(int i=0; i<iCount; i++)
{
iLength = (WORD)SendMessage(hEdit, EM_LINELENGTH, i, 0);
Lines[i] = new TCHAR[iLength+sizeof(WORD)+1];
CopyMemory(Lines[i], &iLength, sizeof(WORD));
SendMessage(hEdit, EM_GETLINE, i, (LPARAM)Lines[i]);
Lines[i][iLength] = '\0';
}
//Visually Verify Contents of the Lines[][] array
HDC hdc;
HFONT hFont;
PAINTSTRUCT ps;
RECT rect;
rect.left = 250;
rect.top = 250;
rect.right = 600;
rect.bottom = 500;
InvalidateRect(hwnd, &rect, TRUE);
hdc = BeginPaint(hwnd, &ps);
hFont = (HFONT)GetStockObject(SYSTEM_FONT);
SelectObject(hdc, hFont);
for(int i=0, x=300, y=275; i<iCount; i++)
TextOut(hdc, x, y+=20, Lines[i], lstrlen(Lines[i]));
DeleteObject(hFont);
EndPaint(hwnd, &ps);
}