From: Larry Lindstrom on
Hi Folks:

Developing on XP Media, with VC6, WIN32, no MFC.

A google of "*win32" groups with with "NMTVCUSTOMDRAW" in the
body came up empty. Search of any post to this newsgroup with
"NMCUSTOMDRAW" anywhere in the body also came up dry. Variants
on those themes were also empty.

And I'm having a bad day to.

Out of many listboxes, one always returns -1 to
SendMessage(..., LB_GETCURSEL, ...) after double clicking, and
out of 11 identical combo boxes that use the same function to
service their button clicks, one does the same in response to
CB_GETCURSEL.

I can't look at those anymore, I need to take my mind off of
them with a little custom draw on a treeview.

I do a lot of owner draw on listboxes and combo boxes, but
I'm not familiar with customdraw. So I've studied an MSDN
page on the subject.

I have the treeview setup to draw white text on a blue
backgroud. I want to reverse that for the selected item.

CDDS_PREPAINT is received, and CDRF_NOTIFYITEMDRAW is
returned.

At this point, according to MSDN, "If CDRF_NOTIFYITEMDRAW
was returned in the previous step, the next NM_CUSTOMDRAW
notification has dwDrawStage set to CDDS_ITEMPREPAINT."

My switch statement never sees the CDDS_ITEMPREPAINT.

Here is the code to custom draw the treeview:

DWORD process_main_menu_tree_custom_draw(HWND hdlg,
NMTVCUSTOMDRAW
*tv_custom_draw_nmhdr_ptr)
{
DWORD return_val = 0;
NMCUSTOMDRAW *custom_draw_nmhdr_ptr = NULL;

if(tv_custom_draw_nmhdr_ptr != NULL)
{
custom_draw_nmhdr_ptr = &tv_custom_draw_nmhdr_ptr->nmcd;

switch(custom_draw_nmhdr_ptr->dwDrawStage)
{
case CDDS_PREPAINT:

return_val = CDRF_NOTIFYITEMDRAW;

break;

case CDDS_ITEMPREPAINT:

if(custom_draw_nmhdr_ptr->uItemState ==
CDIS_SELECTED)
{
// The item is selected. Inverse the text and
// background colors.
SetTextColor(custom_draw_nmhdr_ptr->hdc,
BLUE_COLOR);

SetBkColor(custom_draw_nmhdr_ptr->hdc,
WHITE_COLOR);

#if 0
tv_custom_draw_nmhdr_ptr->clrText = BLUE_COLOR;
tv_custom_draw_nmhdr_ptr->clrTextBk =
WHITE_COLOR;

return_val = CDRF_NEWFONT;
#endif
}

break;
}
}

return return_val;
}

I'm not sure if I'm supposed to use SetTxtColor() or clrText
to set the color, but I don't think it matters much if the
CDDS_ITEMPREPAINT draw stage is never received.

What am I doing wrong now?

Looks like it's back to those listbox and combo problems.

I've had better Saturday nights.

Thanks
Larry
 | 
Pages: 1
Prev: CAtlmap Crash on vista
Next: Newbie question