NM_CUSTOMDRAW Message
NM_CUSTOMDRAW Message

Sent by some common controls to notify their parent windows about drawing operations. This notification is sent in the form of a WM_NOTIFY message.

Syntax

To send this message, call the SendMessage function as follows.
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

lpNMCustomDraw
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.
List view
NMLVCUSTOMDRAW
Tooltip
NMTTCUSTOMDRAW
Tree view
NMTVCUSTOMDRAW
Toolbar
NMTBCUSTOMDRAW
All other supported controls
NMCUSTOMDRAW

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.

CDRF_NOTIFYITEMDRAWThe control will notify the parent of any item-related drawing operations. It will send NM_CUSTOMDRAW notification messages before and after drawing items. This occurs when dwDrawStage equals CDDS_PREPAINT.
CDRF_NOTIFYPOSTERASEThe control will notify the parent after erasing an item. This occurs when dwDrawStage equals CDDS_PREPAINT.
CDRF_NOTIFYPOSTPAINTThe control will notify the parent after painting an item. This occurs when dwDrawStage equals CDDS_PREPAINT.
CDRF_NEWFONTYour 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_NOTIFYSUBITEMDRAWVersion 4.71. Your application will receive an NM_CUSTOMDRAW message 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_SKIPDEFAULTYour application drew the item manually. The control will not draw the item. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.
CDRF_DOERASEdraw the background
CDRF_SKIPPOSTPAINTdon't draw the focus rect

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 are running Windows XP and 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 Function.

Message Information

Minimum DLL Versioncomctl32.dll version 4.70 or later
Headercommctrl.h
Minimum operating systems Windows 2000, Windows NT 4.0 with Internet Explorer 3.0, Windows 98, Windows 95 with Internet Explorer 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
Page view tracker