// NOTES:
// m_documentList is a member variable of the view class
// pDoc->m_files is an array of CStrings
CArchieDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// get the size of the view window
CRect rect;
this->GetClientRect( &rect );
// create list view
m_documentList.Create( WS_VISIBLE | WS_CHILD | WS_BORDER |
LVS_REPORT | LVS_SINGLESEL,
rect, this, IDC_DOCLIST );
// insert column
LV_COLUMN col;
col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | VCF_SUBITEM;
col.fmt = LVCFMT_LEFT;
col.cx = 150;
col.iSubItem = 0;
col.pszText = "Filename";
m_documentList.InsertColumn( 0, &col );
// insert rows
for ( int n = 0; n < pDoc->m_files.GetSize(); n++ )
{
m_documentList.InsertItem( n, pDoc->m_files.GetAt( n ));
}
I have this code in a member function CreateDocumentList()
in my view class. When I call this function in OnDraw() I
get a debug assertion failure. I tracked it to the call to
m_documentList.Create(), which is pretty obvious.
What can I do to get it right? I think the pointer to the
owner of the listview is not correct, but that's only
guessing, and I dont know how to fix it. Any suggestions??
regards,
Erik
> I have this code in a member function CreateDocumentList()
> in my view class. When I call this function in OnDraw() I
> get a debug assertion failure. I tracked it to the call to
> m_documentList.Create(), which is pretty obvious.
> m_documentList.Create( WS_VISIBLE | WS_CHILD | WS_BORDER |
Are you saying that above line is called each time OnDraw is executed ? If
yes, this is wrong and MFC ensures that you call "m_documentList.Create"
only once, thus the assert failure(OnDraw is called each time you need to
redraw your view).
Make sure you call "m_documentList.Create" just once.
--
Regards,
Kobi Ben Tzvi
"Erik" <er...@thesixthhouse.nl> wrote in message
news:07c801c38208$73e877f0$a101...@phx.gbl...