Hi,
I'm trying to add a drop down combo box for user selection in the main window of my application. The program reads USERS.txt, loads each line into a const char*[] and (hopefully) adds them to the combo box. The problem is my program displays Chinese characters instead of the content of the .txt file.
This is my first C++ and first Win32 project, any insight is helpful
const char* users[50];
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance;
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, 575, 700, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
HWND hwndSelectUser = CreateWindow (TEXT("COMBOBOX"),
TEXT("User:"),
WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN | WS_VSCROLL,
200, 450, 150, 60,
hWnd,
(HMENU) ID_USERCOMBO,
hInstance,
NULL);
int y = LoadUsers();
for(int i = 0; i < y; i ++){
SendMessage(hwndSelectUser, CB_ADDSTRING, 0, reinterpret_cast<LPARAM> ((LPCTSTR)users[i]));
}
}
int LoadUsers(){
string line;
int counter = 0;
ifstream userlistfile ("USERS.txt");
if(userlistfile.is_open()){
while(userlistfile.good()){
getline (userlistfile, line);
users[counter] = line.c_str();
counter++;
}
}
return counter;
}
-Ben