List View troubles (adding items)
I did some searching on here, msdn, and codeguru and didn't find anything I was looking for. I cannot successfully add an item to my list view. I have 3 columns in my list view, all of which are visible, but when I try to add an item so I can add text the ListView_InsertItem() macro fails every time. I don't know where I went wrong. I basically took novacain's code from searches and still nothing. Here is my function, and I call it at the end of WM_INITDIALOG.
Code:
bool AddItem(int index, int col, char* text, HWND hwnd)
{
LVITEM LvI;
LvI.mask = LVIF_TEXT | LVIF_PARAM;
LvI.iItem = index;
LvI.iImage = 0;
LvI.state = 0;
LvI.iSubItem = 0;
LvI.pszText = text;
LvI.cchTextMax = lstrlen(text);
LvI.lParam = 0;
if(ListView_InsertItem(hwnd, &LvI))
MessageBox(hwnd,"item added","",MB_OK); //this message shows if i put
//if(!ListView_InsertItem(blah blah)) so it's returning -1
if(col > 0)
ListView_SetItemText(hwnd, 1,1,text);
}