In my application, I create a modal dialog that contains a mfc List Control. When I don't initialize any columns or items in the List Control, the dialog shows without error. When I try to add a column to the List Control, I get the following Debug Assertion Failed message:
If it helps, the breakpoint is at
_AFXCMN_INLINE int CListCtrl::InsertColumn(int nCol, const LVCOLUMN* pColumn) { ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn); }
I am trying to add the column headers with the following code in OnInitDialog()
:
BOOL EventL::OnInitDialog()
{
m_ListEventLog.InsertColumn(0, _T("Description"), LVCFMT_LEFT, 250); //Failure happens HERE
//m_ListEventLog.InsertColumn(0, "Description", LVCFMT_LEFT, 200, 0); //I have also tried things such as this.
return FALSE;
}
I add column headers to other CListControls in my application in this way, without problems. The modal dialog is called with the code:
void ListOption::OnBnClickedEventLog()
{
EventL eventLog;
eventLog.DoModal();
}