WM DRAWITEM: Difference between revisions
Line 155: | Line 155: | ||
:::;''hwnd'' ([[HWND]]) - Slider window handle. | :::;''hwnd'' ([[HWND]]) - Slider window handle. | ||
:::;''hps'' ([[HPS]]) - Presentation-space handle. | :::;''hps'' ([[HPS]]) - Presentation-space handle. | ||
:::;''fsState'' (ULONG) - Slider window style flags. See | :::;''fsState'' (ULONG) - Slider window style flags. See Slider Control Styles for descriptions of these style flags. | ||
:::;''fsAttribute'' (ULONG) - Reserved. | :::;''fsAttribute'' (ULONG) - Reserved. | ||
:::;''fsStateOld'' (ULONG) - Reserved. | :::;''fsStateOld'' (ULONG) - Reserved. |
Revision as of 04:18, 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.
- in Notebook Controls
This notification message is sent to the owner of a notebook control each time a tab's content is to be drawn by the owner of the notebook. The tab's content is drawn by the owner unless the owner sets the tab text or bit map by sending a BKM_SETTABTEXT or BKM_SETTABBITMAP message, respectively, to the notebook control.
- in Slider Controls
If the SLS_OWNERDRAW style bit is set for a slider control, this notification message is sent to that slider control's owner whenever the slider shaft, ribbon strip, slider arm, and slider background are to be drawn.
- in Value Set Controls
This notification message is sent to the owner of a value set control each time an item that has the VIA_OWNERDRAW attribute is to be drawn, or when the background of a value set window that has the VS_OWNERDRAW style bit 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. */
in Notebook Controls
param1 USHORT id /* Window identifier. */ param2 POWNERITEM powneritem /* Pointer to an OWNERITEM data structure. */
in Slider Controls
param1 USHORT id /* Window identifier. */ param2 POWNERITEM powneritem /* Pointer to an OWNERITEM data structure. */
in Value Set Controls
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.
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.
in Notebook Controls
- id (USHORT) - input
- Window identifier. The window identifier of the notebook control sending this notification message.
- powneritem (POWNERITEM) - input
- Pointer to an OWNERITEM data structure. The following list defines the OWNERITEM data structure fields that apply to the notebook control.
- hwnd (HWND) - Notebook window handle.
- hps (HPS) - Presentation-space handle.
- fsState (ULONG) - Notebook window style flags. See Notebook Styles for an Old Notebook and Notebook Styles for a New Notebook for descriptions of these style flags.
- fsAttribute (ULONG) - Page attribute flags for the tab page. See BKM_INSERTPAGE for descriptions of these attribute flags.
- fsStateOld (ULONG) - Reserved.
- fsAttributeOld (ULONG) - Reserved.
- rclItem (RECTL) - Tab rectangle to be drawn in window coordinates.
- idItem (LONG) - Reserved.
- hItem (ULONG) - Current page ID (ulPageId) for which the content of a tab is to be drawn.
in Slider Controls
- id (USHORT) - input
- Window identifier. The window identifier of the slider control sending this notification message.
- powneritem (POWNERITEM) - input
- Pointer to an OWNERITEM data structure. The following list defines the OWNERITEM data structure fields that apply to the slider control. See OWNERITEM for the default field values.
- hwnd (HWND) - Slider window handle.
- hps (HPS) - Presentation-space handle.
- fsState (ULONG) - Slider window style flags. See Slider Control Styles for descriptions of these style flags.
- fsAttribute (ULONG) - Reserved.
- fsStateOld (ULONG) - Reserved.
- fsAttributeOld (ULONG) - Reserved.
- rclItem (RECTL) - Item rectangle to be drawn in window coordinates.
- idItem (LONG) - Identity of item to be drawn
- SDA_SLIDERSHAFT: Specifies that the slider shaft is to be drawn.
- SDA_RIBBONSTRIP: Specifies that the slider shaft area that contains a ribbon strip is to be drawn.
- SDA_SLIDERARM: Specifies that the slider arm is to be drawn.
- SDA_BACKGROUND: Specifies that the slider background is to be drawn.
- hItem (ULONG) - Reserved.
in Value Set Controls
- id (USHORT) - input
- Window identifier. The window identifier of the value set control sending this notification message.
- powneritem (POWNERITEM) - input
- Pointer to an OWNERITEM data structure. The following list defines the OWNERITEM data structure fields that apply to the value set control. See OWNERITEM for the default field values.
- hwnd (HWND) - Value set window handle.
- hps (HPS) - Presentation-space handle.
- fsState (ULONG) - Value set window style flags. See Value Set Control Styles for descriptions of these style flags.
- fsAttribute (ULONG) - Item attribute flags for the indexed item. See VM_SETITEMATTR for descriptions of these attribute flags.
- fsStateOld (ULONG) - Reserved.
- fsAttributeOld (ULONG) - Reserved.
- rclItem (RECTL) - Item rectangle to be drawn in window coordinates.
- idItem (LONG) - Identity of component to be drawn.
- VDA_BACKGROUND: Specifies that a part of the value set background is to be drawn.
- VDA_SURROUNDING: Specifies that a part of the area surrounding the value set is to be drawn.
- VDA_ITEMBACKGROUND: Specifies that the background of an item is to be drawn.
- VDA_ITEM: Specifies that an entire item is to be drawn.
- hItem (ULONG) - If the value of the identity parameter is VDA_ITEMBACKGROUND or VDA_ITEM, this is the current row and column index of the item to be drawn. The low-order word contains the row index, and the high-order word contains the column index. Otherwise, this is 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.
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.
in Notebook Controls
- rc (BOOL) - returns
- Content-drawn indicator.
- TRUE: The owner draws the tab's content.
- FALSE: If the owner does not draw the tab's content, the owner returns this value and the notebook control draws the tab's content.
in Slider Controls
- 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 slider control draws the item.
in Value Set Controls
- rc (BOOL) - returns
- Item-drawn indicator.
- TRUE: The owner draws the component.
- FALSE: If the owner does not draw the component, the owner returns this value and the value set control draws the component.
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.
in Notebook Controls
If an application uses notebook controls that contain tab pages, the default condition is for the application to draw the contents of the tab each time a tab page is displayed. This situation applies particularly if the content of the tab is not one of the supported formats.
The notebook control window procedure generates this message and sends it to its owner, informing the owner that the content of a tab is to be drawn. The owner is given the opportunity to draw the content of the tab and to indicate that the content of the tab has been drawn or that the notebook control is to draw it. To indicate that the notebook control is to draw the content of the tab, the owner sends either a BKM_SETTABTEXT or a BKM_SETTABBITMAP message to the notebook control.
in Slider Controls
The slider control provides this message to give the application the opportunity to provide a custom slider shaft, custom ribbon strip, custom slider arm, and custom background. The application can specify one or all of these items and is given the opportunity to do so.
The slider control window procedure generates this message and sends it to its owner, informing the owner that an item is to be drawn. The owner is then given the opportunity to draw that item, and to indicate that an item has been drawn or that the slider control is to draw it.
in Value Set Controls
The value set control draws only items that are represented in one of the formats described: text, color, bit maps, or icons.
If an application uses value set controls that contain items that are not represented by the supported formats or requires that the emphasized attribute of an item is to be drawn in a special manner, the application must specify those items as VIA_OWNERDRAW and those items must be drawn by the owner.
Through this message, the application can provide a custom value set background (the area between the items) and customize the area surrounding the value set (the area on the top and right sides of the value set that is left over when the value set calculates its size). The application can specify how either or both of these areas are drawn and is given the opportunity to do so.
The value set control window procedure generates this message and sends it to its owner, informing the owner that something is to be drawn. The owner is given the opportunity to draw and to indicate whether the value set control should continue with the normal drawing of that component.
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)