laiason5
May 31st, 1999, 10:08 AM
i have posted on the forum for the past week and so far have not gotten any suggestions that work. all i need to do is get this **** list control to add items to the display and it refuses to do it. every time i add an item to it, it sets the item text to null(i.e. "").if i try to set the item text, it gives a debug assertion failure. Here below is the code for the SetItemText function of CListCtrl. It gives a debug assertion in this line:
BOOL CListCtrl::SetItemText(int nItem, int nSubItem, LPCTSTR lpszText)
{
ASSERT(::IsWindow(m_hWnd));
ASSERT((GetStyle() & LVS_OWNERDATA)==0); //This causes debug assertion failure(or at least thats what the debugger tells me
LVITEM lvi;
lvi.iSubItem = nSubItem;
lvi.pszText = (LPTSTR) lpszText;
return (BOOL) ::SendMessage(m_hWnd, LVM_SETITEMTEXT, nItem, (LPARAM)&lvi);
}
my list controls are initialized and accessed like this:
CListCtrl m_listCtrl2; //this is in my header
CListCtrl m_listCtrl; //this is in my header
DDX_Control(pDX, IDC_LIST2, m_listCtrl2);//this is in DoDataExchange(...), it initializes it i think
DDX_Control(pDX, IDC_LIST, m_listCtrl);//this is in DoDataExchange(...), it initializes it i think
//These are in my OnInitDlg(...)
m_listCtrl.InsertColumn(0, CString("Questions:"), LVCFMT_LEFT, bounds.Width(),0);
m_listCtrl2.InsertColumn(0, CString("Answers:"), LVCFMT_LEFT, bounds.Width(),0);
//this is how im adding to my List
int i = m_listCtrl.GetItemCount(); //first time through returns 0
m_listCtrl.InsertItem(i, dlg.m_textQ);//works as far as i can tell
CString t = "Test"; //test string init
t = m_listCtrl.GetItemText(1,0); //t's value goes from "Test" to ""
m_listCtrl.SetItemText(i, 0, dlg.m_textQ); //must comment out to run(or i get debug assertion failure)
i = m_listCtrl.GetItemCount(); //this returns 1 instead of 0 so i have added the item
i have been working forever on this and any help would be great. i think that i have included all references to my CListCtrl variables so if you dont see something in here, it wasnt added by me to the code. so... HELP!!!
thanks
L5
BOOL CListCtrl::SetItemText(int nItem, int nSubItem, LPCTSTR lpszText)
{
ASSERT(::IsWindow(m_hWnd));
ASSERT((GetStyle() & LVS_OWNERDATA)==0); //This causes debug assertion failure(or at least thats what the debugger tells me
LVITEM lvi;
lvi.iSubItem = nSubItem;
lvi.pszText = (LPTSTR) lpszText;
return (BOOL) ::SendMessage(m_hWnd, LVM_SETITEMTEXT, nItem, (LPARAM)&lvi);
}
my list controls are initialized and accessed like this:
CListCtrl m_listCtrl2; //this is in my header
CListCtrl m_listCtrl; //this is in my header
DDX_Control(pDX, IDC_LIST2, m_listCtrl2);//this is in DoDataExchange(...), it initializes it i think
DDX_Control(pDX, IDC_LIST, m_listCtrl);//this is in DoDataExchange(...), it initializes it i think
//These are in my OnInitDlg(...)
m_listCtrl.InsertColumn(0, CString("Questions:"), LVCFMT_LEFT, bounds.Width(),0);
m_listCtrl2.InsertColumn(0, CString("Answers:"), LVCFMT_LEFT, bounds.Width(),0);
//this is how im adding to my List
int i = m_listCtrl.GetItemCount(); //first time through returns 0
m_listCtrl.InsertItem(i, dlg.m_textQ);//works as far as i can tell
CString t = "Test"; //test string init
t = m_listCtrl.GetItemText(1,0); //t's value goes from "Test" to ""
m_listCtrl.SetItemText(i, 0, dlg.m_textQ); //must comment out to run(or i get debug assertion failure)
i = m_listCtrl.GetItemCount(); //this returns 1 instead of 0 so i have added the item
i have been working forever on this and any help would be great. i think that i have included all references to my CListCtrl variables so if you dont see something in here, it wasnt added by me to the code. so... HELP!!!
thanks
L5