Hi,
I need some help. I have an application with a ListView in the main window. From the menu I can open a dialog to add items to the listview. But it doesn't work. I get this error when I try to add a item:
Debug Assertion Failed!
Program: ...
File: f:\rtm\vctools\vc7libs\ship\atlmfc\include\afx.cmn.inl
Line: 148
When I click on the OK button in the dialog, it takes the text from a edit control, put it in 'CString ItemTxt' and calls the function below:
void CApplicationView::AddItem(CString ItemTxt)
{
// Converts CString to char
const size_t newsize = 100;
char n_ItemString[newsize];
strcpy_s(n_ItemString, ItemTxt);
CListCtrl& ListCtrl = GetListCtrl();
LV_ITEM lvi;
lvi.mask = LVIF_TEXT;
lvi.iItem = 0;
lvi.iSubItem = 0;
lvi.pszText = n_ItemString;
ListCtrl.InsertItem(&lvi);
}
Does anyone have any idea whats wrong? Please help me!
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).