Click to See Complete Forum and Search --> : CListView::DrawItem() never called


Scott
June 3rd, 1999, 03:40 PM
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

cdehaven
June 3rd, 1999, 04:03 PM
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

Vicky
June 3rd, 1999, 11:58 PM
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().

Vicky
June 4th, 1999, 12:00 AM
You have to set LVS_OWNERDRAWFIXED. Otherwise you won't get DrawItem().