WM DRAWITEM: Difference between revisions
Created page with "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== <pre> param1 USHORT idIdentity; →Window identifier.: param2 ULONG ulcontrolspec; →Control-specific information.: </pre> ===in Container Controls=== <pre> p..." |
No edit summary |
||
Line 3: | Line 3: | ||
;in Font Dialog | ;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. | 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. | ||
;in List Boxes | |||
This notification is sent to the owner of a list box control each time an item is to be drawn. | |||
;in Menu Controls | |||
This notification is sent to the owner of a menu control each time an item is to be drawn. | |||
==Syntax== | ==Syntax== | ||
Line 29: | Line 35: | ||
param2 | param2 | ||
POWNERITEM pOwnerItem /* Pointer to an OWNERITEM data structure. */ | POWNERITEM pOwnerItem /* Pointer to an OWNERITEM data structure. */ | ||
</pre> | |||
===in List Boxes=== | |||
<pre> | |||
param1 | |||
USHORT idListBox /* Window identifier. */ | |||
param2 | |||
POWNERITEM pOwnerItem /* Owner-item structure. */ | |||
</pre> | |||
===in Menu Controls=== | |||
<pre> | |||
param1 | |||
USHORT idMenu /* Window identifier. */ | |||
param2 | |||
POWNERITEM pOwnerItem /* Owner-item structure. */ | |||
</pre> | </pre> | ||
Line 70: | Line 94: | ||
:::;''idItem'' (LONG) - Reserved. | :::;''idItem'' (LONG) - Reserved. | ||
:::;''hItem'' ([[CNRDRAWITEMINFO]]) - Reserved. | :::;''hItem'' ([[CNRDRAWITEMINFO]]) - Reserved. | ||
===in List Boxes=== | |||
;''idListBox'' ([[USHORT]]) - input: Window identifier. The window identity of the list box control sending this notification message. | |||
;''pOwnerItem'' ([[POWNERITEM]]) - input: Owner-item structure. This points to an owner-item structure; see [[OWNERITEM]]. | |||
===in Menu Controls=== | |||
;''idMenu'' ([[USHORT]]) - input: Window identifier. The window identity of the menu control sending this notification message. | |||
;''pOwnerItem'' ([[POWNERITEM]]) - input: Owner-item structure. This points to an owner-item structure; see [[OWNERITEM]]. | |||
==Returns== | ==Returns== | ||
Line 85: | Line 119: | ||
::TRUE: The owner draws the item. | ::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. | ::FALSE: If the owner does not draw the item, the owner returns this value and the font dialog draws the item. | ||
===in List Boxes=== | |||
;''rc'' ([[BOOL]]) - returns: Item-drawn indicator. | |||
::TRUE: The owner draws the item, so the list box 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 list box control draws the item. | |||
===in Menu Controls=== | |||
;''rc'' ([[BOOL]]) - returns: Item-drawn indicator. | |||
::TRUE: The owner draws the item, and so the menu 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 menu control draws the item. | |||
Line 101: | Line 146: | ||
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. | 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. | ||
===in Frame Controls=== | |||
The identity of the top-level action-bar menu that generated this message is found. If the identity is FID_MENU, the message is passed to the window with identity FID_CLIENT. | |||
===in List Boxes=== | |||
The list box control window procedure only draws items that are represented by text strings and emphasizes selected items by inverting them. | |||
If an application uses list box controls containing items that are not represented by text strings, or requires that the emphasized state of an item is to be drawn in a special manner, the list box control must specify the style LS_OWNERDRAW and those items must be drawn by the owner. | |||
The list box control window procedure generates this message and sends it to the owner of the list box control, informing the owner that an item is to be drawn, offering the owner the opportunity to draw that item, and indicating that either the item has been drawn, or that the list box control is to draw it. | |||
The item text must not be changed during the processing of this message. | |||
===in Menu Controls=== | |||
The menu control window procedure only draws items that are represented by text strings and emphasizes selected items by inverting them. | |||
If an application uses menu controls containing items that are not represented by text strings, or requires that the emphasized state of an item is to be drawn in a special manner, then the menu control must specify the style MIS_OWNERDRAW and those items must be drawn by the owner. | |||
The menu control window procedure generates this message and sends it to its owner, 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 menu control is to draw it. | |||
==Default Processing== | ==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. | 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. | ||
===in Frame Controls=== | |||
The default window procedure takes no action on this message, other than to set ulReserved to 0. | |||
Revision as of 03:04, 19 April 2025
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.
- in List Boxes
This notification is sent to the owner of a list box control each time an item is to be drawn.
- in Menu Controls
This notification is sent to the owner of a menu control each time an item 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. */
in List Boxes
param1 USHORT idListBox /* Window identifier. */ param2 POWNERITEM pOwnerItem /* Owner-item structure. */
in Menu Controls
param1 USHORT idMenu /* Window identifier. */ param2 POWNERITEM pOwnerItem /* Owner-item 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.
in List Boxes
- idListBox (USHORT) - input
- Window identifier. The window identity of the list box control sending this notification message.
- pOwnerItem (POWNERITEM) - input
- Owner-item structure. This points to an owner-item structure; see OWNERITEM.
in Menu Controls
- idMenu (USHORT) - input
- Window identifier. The window identity of the menu control sending this notification message.
- pOwnerItem (POWNERITEM) - input
- Owner-item structure. This points to an owner-item structure; see OWNERITEM.
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.
in List Boxes
- rc (BOOL) - returns
- Item-drawn indicator.
- TRUE: The owner draws the item, so the list box 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 list box control draws the item.
in Menu Controls
- rc (BOOL) - returns
- Item-drawn indicator.
- TRUE: The owner draws the item, and so the menu 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 menu control 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.
in Frame Controls
The identity of the top-level action-bar menu that generated this message is found. If the identity is FID_MENU, the message is passed to the window with identity FID_CLIENT.
in List Boxes
The list box control window procedure only draws items that are represented by text strings and emphasizes selected items by inverting them.
If an application uses list box controls containing items that are not represented by text strings, or requires that the emphasized state of an item is to be drawn in a special manner, the list box control must specify the style LS_OWNERDRAW and those items must be drawn by the owner.
The list box control window procedure generates this message and sends it to the owner of the list box control, informing the owner that an item is to be drawn, offering the owner the opportunity to draw that item, and indicating that either the item has been drawn, or that the list box control is to draw it.
The item text must not be changed during the processing of this message.
in Menu Controls
The menu control window procedure only draws items that are represented by text strings and emphasizes selected items by inverting them.
If an application uses menu controls containing items that are not represented by text strings, or requires that the emphasized state of an item is to be drawn in a special manner, then the menu control must specify the style MIS_OWNERDRAW and those items must be drawn by the owner.
The menu control window procedure generates this message and sends it to its owner, 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 menu control is to draw it.
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.
in Frame Controls
The default window procedure takes no action on this message, other than to set ulReserved to 0.
Related Messages
- WM_DRAWITEM (in Frame Controls)
- WM_DRAWITEM (in List Boxes)
- WM_DRAWITEM (in Menu Controls)