I have the following block of code:
for( CarsPool::CarRecord &record : recs->GetRecords())
{
LVITEM item;
item.mask = LVIF_TEXT;
item.cchTextMax = 6;
item.iSubItem = 0;
item.pszText = (LPSTR)(record.getCarName().c_str()); //breakpoint on this line.
item.iItem = 0;
ListView_InsertItem(CarsListView, &item);
item.iSubItem = 1;
item.pszText = TEXT("Available");
ListView_SetItem(CarsListView, &item);
item.iSubItem = 2;
item.pszText = (LPSTR)CarsPool::EncodeCarType(record.getCarType());
ListView_SetItem(CarsListView, &item);
}
The information from Visual Studio Debugger is here:
Why isn't the program able to read the characters from string?
A test has shown me that it works in this way:
MessageBox(hWnd, (LPSTR)(record.getCarName().c_str()), "Test", MB_OK);