Like all Windows-based applications, common controls paint and erase themselves based on messages received from the system or other applications. The process of a control painting or erasing itself is called a paint cycle. Controls that support custom draw send NM_CUSTOMDRAW notification messages periodically throughout each paint cycle. This notification message is accompanied by an NMCUSTOMDRAW structure or another structure that contains an NMCUSTOMDRAW structure as its first member.
In addition to other information, the NMCUSTOMDRAW structure informs the parent window about what stage of the paint cycle the control is in. This is referred to as the draw stage, and is represented by the value in the structure's dwDrawStage member. A control informs its parent about four basic, or global, draw stages. The flag values, defined in Commctrl.h, that represent these stages in the structure are described in the following table.
Global draw stage value | Description |
---|---|
CDDS_PREPAINT | Before the paint cycle begins. |
CDDS_POSTPAINT | After the paint cycle is complete. |
CDDS_PREERASE | Before the erase cycle begins. |
CDDS_POSTERASE | After the erase cycle is complete. |
Each of the preceding values can be combined with the CDDS_ITEM flag to specify draw stages for items. Item-specific values contained in Commctrl.h are described in the following table.
Item-specific draw stage value | Description |
---|---|
CDDS_ITEMPREPAINT | Before an item is drawn. |
CDDS_ITEMPOSTPAINT | After an item has been drawn. |
CDDS_ITEMPREERASE | Before an item is erased. |
CDDS_ITEMPOSTERASE | After an item has been erased. |
You must process the NM_CUSTOMDRAW notification message and then return a specific value that informs the control what it must do.