From: Larry Lindstrom on 6 May 2007 02:13
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
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
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,
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;
return_val = CDRF_NOTIFYITEMDRAW;
// The item is selected. Inverse the text and
// background colors.
tv_custom_draw_nmhdr_ptr->clrText = BLUE_COLOR;
return_val = CDRF_NEWFONT;
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.