WM DRAWITEM
This notification is sent to the owner of a control each time an item is to be drawn.
- in Font Dialog
If the FNTS_OWNERDRAWPREVIEW style is set for a font dialog, this notification message is sent to that dialog's owner whenever the preview window area (sample text) is to be drawn.
Syntax
param1 USHORT idIdentity; /* Window identifier. */ param2 ULONG ulcontrolspec; /* Control-specific information. */
in Container Controls
param1 USHORT id /* Container control ID. */ param2 POWNERITEM pOwnerItem /* Pointer to an OWNERITEM data structure. */
in Font Dialog
param1 USHORT id /* Window identifier. */ param2 POWNERITEM pOwnerItem /* Pointer to an OWNERITEM data structure. */
Parameters
- idIdentity (USHORT) - input
- The window identity of the control sending this notification message.
- ulcontrolspec (ULONG) - input
- Control-specific information. The meaning of the control-specific information depends on the type of control. For details of each control type, refer to the appropriate section.
in Container Controls
- id (USHORT) - input
- Container control ID.
- pOwnerItem (POWNERITEM) - input
- Pointer to an OWNERITEM data structure. The following list defines the OWNERITEM data structure fields as they apply to the container control. See OWNERITEM for the default field values.
- hwnd (HWND) - Handle of the window in which ownerdraw will occur. The following is a list of the window handles that can be specified for ownerdraw
-
- The container window handle of the icon, name, text, and tree views
- The container title window handle
- The left or right window handles of the details view
- The left or right column heading windows of the details view.
- hps (HPS) - Handle of the presentation space of the container window. For the details view that uses a split bar, the presentation space handle is either for the left or right window, depending upon the position of the column. If the details view does not have a split bar, the presentation space handle is for the left window.
- fsState (ULONG) - Specifies emphasis flags. This state is not used by the container control because the application is responsible for drawing the emphasis states during ownerdraw.
- fsAttribute (ULONG) - Attributes of the record as given in the flRecordAttr field in the RECORDCORE data structure.
- Note: If the CCS_MINIRECORDCORE style bit is specified when a container is created, then MINIRECORDCORE should be used instead of RECORDCORE and PMINIRECORDCORE should be used instead of PRECORDCORE in all applicable data structures and messages.
- fsStateOld (ULONG) - Previous emphasis. This state is not used by the container control because the application is responsible for drawing the emphasis states during ownerdraw.
- fsAttributeOld (ULONG) - Previous attribute. This state is not used by the container control because the application is responsible for drawing the emphasis states during ownerdraw.
- rclItem (RECTL) - This is the bounding rectangle into which the container item is drawn.
- If the container item is an icon/text or bit-map/text pair, two WM_DRAWITEM messages are sent to the application. The first WM_DRAWITEM message contains the rectangle bounding the icon or bit map and the second contains the rectangle bounding the text.
- If the container item contains only text, or only an icon or bit map, only one WM_DRAWITEM message is sent. However, if the current view is the tree icon or tree text view and if the item is a parent item, the application will receive an additional WM_DRAWITEM (in Container Controls) message. The additional message is for the icon or bit map that indicates whether the parent item is expanded or collapsed.
- If the current view is the details view and the CFA_OWNER attribute is set, the rectangle's size is equal to the width of the column and the height of the tallest field in the container item. CFA_OWNER is an attribute of the FIELDINFO data structure's flData field.
- idItem (ULONG) - Identifies the item being drawn. It can be one of the following
- CMA_CNRTITLE, CMA_ICON, CMA_TEXT, CMA_TREEICON. This field is not used for the details view and is set to 0.
- hItem (CNRDRAWITEMINFO) - Pointer to a CNRDRAWITEMINFO structure.
in Font Dialog
- id (USHORT) - input
- Window identifier. The window ID of the sample area (DID_SAMPLE).
- pOwnerItem (POWNERITEM) - input
- Pointer to an OWNERITEM data structure. The following list defines the OWNERITEM data structure fields as they apply to the font dialog. See OWNERITEM for the default field values.
- hwnd (HWND) - Window handle of the sample area.
- hps (HPS) - Presentation-space handle.
- fsState (ULONG) - Reserved.
- fsAttribute (ULONG) - Reserved.
- fsStateOld (ULONG) - Reserved.
- fsAttributeOld (ULONG) - Reserved.
- rclItem (RECTL) - Item rectangle to be drawn in window coordinates.
- idItem (LONG) - Reserved.
- hItem (CNRDRAWITEMINFO) - Reserved.
Returns
- rc (BOOL) - returns
- Item-drawn indicator.
- TRUE: The owner has drawn the item, and so the control does not draw it.
- FALSE: If the item contains text and the owner does not draw the item, the owner returns this value and the control draws the item.
in Container Controls
- rc (BOOL) - returns
- Item-drawn indicator.
- TRUE: The owner draws the item, and so the container control does not draw it.
- FALSE: If the owner does not draw the item, the owner returns this value and the container control draws the item.
in Font Dialog
- rc (BOOL) - returns
- Item-drawn indicator.
- TRUE: The owner draws the item.
- FALSE: If the owner does not draw the item, the owner returns this value and the font dialog draws the item.
Remarks
A control can only display some types of information, and emphasize items in a control-specific manner. Therefore, if special items are to be displayed or emphasized in a special manner, this must be done by the owner window of the control.
The control window procedure generates this message and sends it to the owner of the control, informing the owner that an item is to be drawn, offering the owner the opportunity to draw that item and to indicate that either the item has been drawn or that the control is to draw it.
in Font Dialog
The font dialog provides this message to give the application the opportunity to provide a custom drawn preview area.
The font dialog default dialog procedure generates this message and sends it to its owner, informing the owner that the preview area is to be drawn. The owner is then given the opportunity to draw that area and to indicate that the area has been drawn or that the font dialog is to draw it.
in Container Controls
CA_OWNERDRAW is an attribute of the CNRINFO data structure's flWindowAttr field.
The container control window procedure generates this message and sends it to the owner of the container control to offer the owner the opportunity to draw that item.
Default Processing
The default window procedure does not expect to receive this message and therefore takes no action on it, other than to set rc to the default value of FALSE.
Related Messages
- WM_DRAWITEM (in Frame Controls)
- WM_DRAWITEM (in List Boxes)
- WM_DRAWITEM (in Menu Controls)