CListView::DrawItem() never called
For whatever reason, I cant get the framework to call DrawItem. I have set the style bits as follows:
BOOL CTransactionView::PreCreateWindow(CREATESTRUCT& cs)
{
//cs.style &= ~LVS_TYPEMASK;
//cs.style &= ~LVS_SHOWSELALWAYS;
//cs.style |= LVS_REPORT | LVS_OWNERDRAWFIXED;
//cs.style |= LVS_EDITLABELS;
return CListView::PreCreateWindow(cs);
}
What am I doing wrong?
Scott
Re: CListView::DrawItem() never called
Hi Scott,
I ended up using a class from one of the examples in MSDN. The class is called CListViewEx and it's included in an example called RowList. Its PreCreateWindow doesn't look much different than yours, but fwiw here it is:
BOOL CListViewEx::PreCreateWindow(CREATESTRUCT& cs)
{
// default is report view and full row selection
cs.style &= ~LVS_TYPEMASK;
cs.style |= LVS_REPORT | LVS_OWNERDRAWFIXED;
m_bFullRowSel = TRUE;
return(CListView::PreCreateWindow(cs));
}
I guess I'm not much help for you, but it may give you another avenue to go down...
Curt
Re: CListView::DrawItem() never called
There is really no need to use CListViewEx. Although the example in the rowlist solves the problem, but the objective of rowlist is to demonstrate the implementation of ownerdrawn CListCtrl. Full row selction has become very very by using LVS_EX_FULLROWSELECT extended style.
DrawItem() can be called for CListView as well as a CListCtrl in a dialog or a CFormView. The only difference being that in FormView or Dialog you have to override OnDrawItem().
Re: CListView::DrawItem() never called
You have to set LVS_OWNERDRAWFIXED. Otherwise you won't get DrawItem().