when i tried to insert an item to the clistctrl,it just isn't working.
the code is shown below.
BOOL SoftwareResource::OnInitDialog() {
CDialogEx::OnInitDialog();
LONG style;
style = GetWindowLong(m_list.m_hWnd, GWL_STYLE);
SetWindowLong(m_list.m_hWnd, GWL_STYLE, style | LVS_REPORT);
m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT |LVS_EX_CHECKBOXES | LVS_EX_DOUBLEBUFFER|LVS_OWNERDATA);
LPCTSTR tab[4] = { _T("PName"),_T("pid"),_T("Thread Num"),_T("Parent id") };
for (int i = 0; i < 4; i++)
{
m_list.InsertColumn(i, tab[i]);
m_list.SetColumnWidth(i, 200);
}
m_list.SetRedraw(FALSE);
LPCTSTR str;
str = _T("madison");
int nRow=m_list.InsertItem(0, str);
m_list.SetItemText(nRow, 0, str);
for (int i = 1; i < 10; i++)
m_list.InsertItem(i, str);
m_list.SetRedraw(TRUE);
return TRUE;
}
What I have tried:
i already set the attribute view as report,yet it still doens't show the text.i could see that there are visible views in the list,but without text.i tried updatedata,setredraw,but it still doesn't work.and when i tried to use setitemtext to set the text,it reported a debug assertion fail.
ps.the insertcolumn is working,though.i don't know why this could work but the insertitem couldn't work.