Based on what I could find in "Custom Draw Reference", I understand I have
to deal with the prepaint notifications and request item-specific
notifications( CDRF_NOTIFYITEMDRAW). I have tried to override the OnNotify
function as follows but I actually never get the CDDS_ITEMPREPAINT draw
stage.
I suspect that overriding the OnNotify function in my view class is not what
I should do?
Any clue?
Thanks
Eric
BOOL CMyOwnView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
LPNMLISTVIEW pnm = (LPNMLISTVIEW)lParam;
switch (pnm->hdr.code)
{
case NM_CUSTOMDRAW:
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
/*
CDDS_PREPAINT is at the beginning of the paint cycle. You
implement custom draw by returning the proper value. In this
case, we're requesting item-specific notifications. */
if(lplvcd->nmcd.dwDrawStage == CDDS_PREPAINT)
{
// Request prepaint notifications for each item.
*pResult = CDRF_NOTIFYITEMDRAW;
}
/*
Because we returned CDRF_NOTIFYITEMDRAW in response to
CDDS_PREPAINT, CDDS_ITEMPREPAINT is sent when the control is
about to paint an item. */
if(lplvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
/*
To change the text and background colors in a list view
control, set the clrText and clrTextBk members of the
NMLVCUSTOMDRAW structure to the desired color.
This differs from most other controls that support
CustomDraw. To change the text and background colors for
the others, call SetTextColor and SetBkColor on the provided
HDC.
*/
lplvcd->clrText = RGB(150, 75, 150);
lplvcd->clrTextBk = RGB(255,255,255);
*pResult = CDRF_NEWFONT;
}
}
default:
break;
}
return CListView::OnNotify(wParam, lParam, pResult);
}
Eric Fleuret <e...@alstom.esca.com> wrote in message
news:e1jE8GUA$GA.296@cppssbbsa04...
Also, the online documentation shows an example with such header:
LRESULT DoNotify(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LPNMLISTVIEW pnm = (LPNMLISTVIEW)lParam; switch (pnm->hdr.code){
case NM_CUSTOMDRAW:{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam; /*
CDDS_PREPAINT is at the beginning of the paint cycle. You
implement custom draw by returning the proper value. In this
case, we're requesting item-specific notifications. */
if(lplvcd->nmcd.dwDrawStage == CDDS_PREPAINT)
// Request prepaint notifications for each item.
return CDRF_NOTIFYITEMDRAW;
<snip>
}
And that's different than the OnNotify() header generated for you...
I also tried ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw) in MessageMap.
Same problem as above.. So I just don't understand that weird stuff.
I am trying to make a CListCtrl you can use to devide data into catagories.
Comparible with GfxListCtrl under "Advanced UI" at www.codeguru.com (but one
that can handle larger number of items without crashing, is more simplified
in use and size, is CListCtrl compatible but supports AddCategory(CString
name) and AddToCatagory(CString catagory, CString item).
I don't want to do a fullblown CustomDraw control.. ;(
Boy am I struggling.. Let me know if you figure it out..
I'll do the same...
Phasy
Eric,
On Fri, 17 Sep 1999 12:21:16 -0700, "Eric Fleuret"
<e...@alstom.esca.com> wrote:
>My view class is using ClistView as its base class and I would like to use
>different colors for some items.
>
>Based on what I could find in "Custom Draw Reference", I understand I have
>to deal with the prepaint notifications and request item-specific
>notifications( CDRF_NOTIFYITEMDRAW). I have tried to override the OnNotify
>function as follows but I actually never get the CDDS_ITEMPREPAINT draw
>stage.
See the following article for an example. If that doesn't do it for
you, post a reply to this thread in this newsgroup and I will post
some code to do what you want.
http://www.codeguru.com/listview/CustomDraw.shtml
Chip
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Make it idiot-proof and someone will make a better idiot."
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-