NM_CUSTOMDRAW notification code

Notifies a control's parent window about custom drawing operations. This notification code is sent in the form of a WM_NOTIFY message.

NM_CUSTOMDRAW

#ifdef LIST_VIEW_CUSTOM_DRAW

    lpNMCustomDraw = (LPNMLVCUSTOMDRAW) lParam;

#elif TOOL_TIPS_CUSTOM_DRAW

    lpNMCustomDraw = (LPNMTTCUSTOMDRAW) lParam;

#elif TREE_VIEW_CUSTOM_DRAW

    lpNMCustomDraw = (LPNMTVCUSTOMDRAW) lParam;

#elif TOOL_BAR_CUSTOM_DRAW

    lpNMCustomDraw = (LPNMTBCUSTOMDRAW) lParam;

#else

    lpNMCustomDraw = (LPNMCUSTOMDRAW) lParam;

#endif

Parameters

lParam

A pointer to a custom draw-related structure that contains information about the drawing operation. The following list specifies the controls and their associated structures.

Control Custom Draw Structure
Rebar, trackbar, and header NMCUSTOMDRAW
List view NMLVCUSTOMDRAW
Tooltip NMTTCUSTOMDRAW
Tree view NMTVCUSTOMDRAW
Toolbar NMTBCUSTOMDRAW

Return value

The value your application can return depends on the current drawing stage. The dwDrawStage member of the associated NMCUSTOMDRAW structure holds a value that specifies the drawing stage. You must return one of the following values.

Return code Description
CDRF_DODEFAULT
The control will draw itself. It will not send additional NM_CUSTOMDRAW notification codes for this paint cycle. This flag cannot be used with any other flag.
CDRF_DOERASE
The control will only draw the background.
CDRF_NEWFONT
Your application specified a new font for the item; the control will use the new font. For more information on changing fonts, see Changing fonts and colors. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.
CDRF_NOTIFYITEMDRAW
The control will notify the parent of any item-related drawing operations. It will send NM_CUSTOMDRAW notification codes before and after drawing items. This occurs when dwDrawStage equals CDDS_PREPAINT.
CDRF_NOTIFYPOSTERASE
The control will notify the parent after erasing an item. This occurs when dwDrawStage equals CDDS_PREPAINT.
CDRF_NOTIFYPOSTPAINT
The control will send an NM_CUSTOMDRAW notification code when the painting cycle for the entire control is complete. This occurs when dwDrawStage equals CDDS_PREPAINT.
CDRF_NOTIFYSUBITEMDRAW
Your application will receive an NM_CUSTOMDRAW notification code with dwDrawStage set to CDDS_ITEMPREPAINT | CDDS_SUBITEM before each list-view subitem is drawn. You can then specify font and color for each subitem separately or return CDRF_DODEFAULT for default processing. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.
CDRF_SKIPDEFAULT
Your application drew the item manually. The control will not draw the item. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.
CDRF_SKIPPOSTPAINT
The control will not draw the focus rectangle around an item.

Remarks

Currently, the following controls support custom draw functionality: header, list view, rebar, toolbar, tooltip, trackbar, and tree view. Custom draw is also supported for button controls if you have an application manifest to ensure that Comctl32.dll version 6 is available.

If this message is handled in a dialog procedure, you must set the return value as part of the window data before returning TRUE. For more information, see DialogProc.

Requirements

Requirement Value
Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
Header
Commctrl.h

See also

Conceptual

Custom Draw