Originally Posted by
hk_mp5kpdw
Seems like it is more a problem of how you are reading the strings read from the file and adding them to the list box than figuring out how many lines are in the file. Show the code you have for doing this. Sounds like you should be using getline to read in items from the file followed by whatever listbox control method to add the strings read from the file into the listbox in question.
This is the function which handles reading from txt file and writeing text to list the box
Code:
BOOL OnInclude(HWND hwndDlg)
{
TCHAR chEnIncl[1024];
HANDLE hFileEn;
DWORD dwSize;
DWORD dw;
LPBYTE lpBuffer = NULL;
hFileEn = CreateFile(TEXT("C:/Program Files/Vocabulary assistant/en.va"), GENERIC_READ, 0,NULL, OPEN_EXISTING, 0, NULL);
if ( hFileEn == INVALID_HANDLE_VALUE )
return FALSE;
dwSize = GetFileSize(hFileEn, NULL);
lpBuffer = (LPBYTE)HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, dwSize+1);
if ( !ReadFile(hFileEn, lpBuffer, dwSize, &dw, NULL) )
{
CloseHandle(hFileEn);
HeapFree(GetProcessHeap(), 0, lpBuffer);
return FALSE;
}
CloseHandle(hFileEn);
lpBuffer[dwSize] = NULL;
SendDlgItemMessage(hwndDlg, IDC_LISTEN, LB_ADDSTRING, NULL, (LPARAM)lpBuffer);
if ( !HeapFree(GetProcessHeap(), 0, lpBuffer) )
return FALSE;
return TRUE;
}