case WM_CREATE: { hList = CreateWindowEx(WS_EX_CLIENTEDGE, L"Listbox", L"", WS_CHILD | WS_VISIBLE | LBS_NOTIFY, 338, 0, 150, 275, hWnd, (HMENU)IDC_LIST, GetModuleHandle(NULL), NULL); WIN32_FIND_DATA FindData; HANDLE hFile = FindFirstFile(L"*.bmp", &FindData); int index = SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)FindData.cFileName); //index = 1st item while(FindNextFile(hFile, &FindData)) { SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)FindData.cFileName); } SendMessage(hList, LB_SETCURSEL, (WPARAM)index, 0); //select first item by default break; } case WM_PAINT: { int index = SendMessage(hList, LB_GETCURSEL, 0, 0); LPCWSTR filename = (LPCWSTR)SendMessage(hList, LB_GETITEMDATA, (WPARAM)index, 0); SetWindowText(hWnd, filename); //gives crap when i select the 1st item, the only 1 i set data break; }