NM_CUSTOMDRAW (list view) Notification

Sent by a list-view control to notify its parent windows about drawing operations. This notification is sent in the form of a WM_NOTIFY message.

Syntax

NM_CUSTOMDRAW

    lpNMCustomDraw = (LPNMLVCUSTOMDRAW) lParam;

Parameters

lpNMCustomDraw
Pointer to a NMLVCUSTOMDRAW structure that contains information about the drawing operation. The first member of this structure, nmcd, is a pointer to an NMCUSTOMDRAW structure. The dwItemSpec member of the structure pointed to by nmcd contains the identifier of the item being drawn and the lItemlParam member contains its application-defined data.

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_DODEFAULTThe control will draw itself. It will not send any additional NM_CUSTOMDRAW messages for this paint cycle. This occurs when dwDrawStage equals CDDS_PREPAINT.
CDRF_DOERASEWindows Vista. The control will not draw the focus rect around an item.
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_NOTIFYITEMERASEWindows NT 4.0 only. The control will notify the parent when an item will be erased. It will send NM_CUSTOMDRAW notification messages before and after erasing 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_NEWFONTThe application specified a new font for the item; the control will use the new font. For more information about 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_SKIPDEFAULTThe application drew the item manually. The control will not draw the item. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.
CDRF_SKIPPOSTPAINTWindows Vista. The control will only paint the background.

Remarks

Version 5.80. If you change the font by returning CDRF_NEWFONT, the list-view control might display clipped text. This behavior is necessary for backward compatibility with earlier versions of the common controls. If you want to change the font of a list-view control, you will get better results if you send a CCM_SETVERSION message with the wParam value set to 5 before adding any items to the control.

Notification Requirements

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 :


Community Content

XenonOfArcticus
Skipping expensive draw on hidden columns
NM_CUSTOMDRAW with CDDS_ITEMPREPAINT | CDDS_SUBITEM and CDDS_ITEMPOSTPAINT | CDDS_SUBITEM will be called in Report view mode even for columns that are not visible. You can optimize expensive draw/lookup operations away by checking the RECT returned from ListView_GetSubItemRect() to make sure RECT.right - RECT.left > 0.
Tags :

Page view tracker