A rendering mode in which you take responsibility for drawing a control, rather
than relying on the control’s default rendering behavior.
Typically, Windows handles painting automatically by using property settings such
as BackColor to determine the appearance of a control. With owner drawing, you take
over the painting process, changing elements of appearance that are not available
by using properties. For example, many controls let you set the color of the text
that is displayed, but you are limited to a single color. Owner drawing enables
you to do things like display part of the text in black and part in red.
In practice, owner drawing is similar to drawing graphics on a form. For example,
you could use graphics methods in a handler for the form's Paint event to emulate
a ListBox control, but you would have to write your own code to handle all
user interaction. With owner drawing, the control uses your code to draw its contents
but otherwise retains all its intrinsic capabilities. You can use
DRAW methods to draw each item in the control or to customize some aspects
of each item while you use the default appearance for other aspects of each item.
DRAW methods based on Device context API
methods and GDI Plus methods. Please, feel free for ask to add new methods if need.
To perform owner drawing in controls that support it, you will typically set one
property and write OnerDraw context script.
Most controls that support owner drawing have an OwnerDraw property that
indicates whether the control will raise its drawing-related event or events when
it paints itself.
There are many different kinds of drawing events, but a typical drawing event occurs
in order to draw a single item within a control. BRIZ provides automaticaly binding
of Your OnerDraw context script when receives an OwnerDraw events. BRIZ sets variables
to drawing. For example, variables typically contains the item's index number, a
Rectangle that indicates the item's display boundaries and for some objects provides
additional information about the item such as the background or a focus rectangle.
OnerDraw context script is reusable (You can use one context with many objects).
For menu You should use the Menu subroutines to
specify an owner-drawn menu item, just add option 'O' to flag and define OwnerDrawContext
name after flag. For example "EO;CONTEXT=MyMenu"
For objects You should specify ownerdraw style and define OwnerDrawContext name with
help of method "SetDrawContextContextName" or
DRAWCONTEXT=xxxxx; option in intial string.
COMBOBOX - CBS_OWNERDRAWFIXED or CBS_OWNERDRAWVARIABLE
HEADER - HDF_OWNERDRAW for item
LISTCTRL - LVS_OWNERDRAWFIXED
TABCTRL - TCS_OWNERDRAWFIXED
STATIC - SS_OWNERDRAW
Owner-Drawn Menus and the WM_MEASUREITEM Message
Before the system displays an owner-drawn menu item for the first time, it sends
the WM_MEASUREITEM message to the window procedure of the window that owns
the item's menu. BRIZ automaticaly calls DrawContext that must fill the itemWidth and itemHeight
members before returning. The system
uses the information in these members when creating the bounding rectangle in which
an application draws the menu item. It also uses the information to detect when
the user chooses the item.
Owner-Drawn Menus and the DRAWITEM
Whenever the item must be drawn (for example, when it is first displayed or when
the user selects it), the system calls the DrawContext. DrawContext contains
flags that indicate the state of the item (such as whether it is grayed or selected)
as well as a bounding rectangle and a device context that the application uses to
draw the item.
An application must do the following while processing the DRAWITEM:
Determine the type of drawing that is necessary. To do so, check the itemAction
member.
Draw the menu item appropriately, using the bounding rectangle. The application must draw only
within the bounding rectangle. For performance reasons, the system does not clip
portions of the image that are drawn outside the rectangle.
If the user selects the menu item, the system sets the itemAction member
to the ODA_SELECT value and sets the
ODS_SELECTED value in the itemState member. This is an application's
cue to redraw the menu item to indicate that it is selected.
DrawContext script predefined values
Array of integer values:
0 - Dialog ID (zero based)
1 - Object ID
2 - reserved
3 - ControlType
The control type. The values for control types are as follows:
ODT_BUTTON (4) Owner-drawn button
ODT_COMBOBOX (3) Owner-drawn combo box
ODT_LISTBOX (2) Owner-drawn list box
ODT_MENU (1) Owner-drawn menu
ODT_LISTVIEW (102) List view control
ODT_STATIC (5) Owner-drawn static control
ODT_TAB (101) Tab control
ODT_HEADER (100) Tab control
4 - ControlID (Windows ID) The control ID for a combo box, list box, or button.
This member is not used for a menu.
5 - The menu-item ID for a menu or the index of the item in a list box or combo
box. For an empty list box or combo box, this member is a negative value, which
allows the application to draw only the focus rectangle at the coordinates specified
by the rcItem member even though there are no items in the control. The user
can thus be shown whether the list box or combo box has the input focus. The setting
of the bits in the itemAction member determines whether the rectangle is
to be drawn as though the list box or combo box has input focus.
6 - Item Action
Defines the drawing action required. This will be one or more of the following bits:
ODA_DRAWENTIRE (0x1) This bit is set when the entire control needs
to be drawn.
ODA_FOCUS (0x4) This bit is set when the control gains or loses input
focus. The itemState member should be checked to determine whether the control
has focus.
ODA_SELECT (0x2) This bit is set when only the selection status
has changed. The itemState member should be checked to determine the new
selection state.
7 - Item State
Specifies the visual state of the item after the current drawing action takes place.
That is, if a menu item is to be dimmed, the state flag ODS_GRAYED will be
set. The state flags are as follows:
ODS_CHECKED (0x0008) This bit is set if the menu item is to
be checked. This bit is used only in a menu.
ODS_DISABLED (0x0004) This bit is set if the item is to be drawn
as disabled.
ODS_FOCUS (0x0010) This bit is set if the item has input focus.
ODS_GRAYED (0x0002) This bit is set if the item is to be dimmed.
This bit is used only in a menu.
ODS_SELECTED (0x0001) This bit is set if the item's status is
selected.
ODS_COMBOBOXEDIT (0x1000) The drawing takes place in the selection
field (edit control) of an ownerdrawn combo box.
ODS_DEFAULT (0x0020) The item is the default item.
ODS_HOTLIGHT (0x0040) Windows 98/Me, Windows 2000/XP:
The item is being hot-tracked, that is, the item will be highlighted when the mouse
is on the item.
ODS_INACTIVE (0x0080) Windows 98/Me, Windows 2000/XP:
The item is inactive and the window associated with the menu is inactive.
ODS_NOACCEL (0x0100) Windows 2000/XP: The control is
drawn without the keyboard accelerator cues.
ODS_NOFOCUSRECT (0x0200) Windows 2000/XP: The control
is drawn without focus indicator cues.
8 - Specifies the window handle of the control for combo boxes, list boxes, and
buttons. Specifies the handle of the menu (HMENU) that contains the item
for menus.
9 - Identifies a device context. This device context must be used when performing
drawing operations on the control.
12 - Specifies the width of a menu item. The DrawContext script of the owner-draw
menu item must fill this member when measure mode flag equal to 1.
13 - Specifies the height of an individual item in a list box or a menu. Before
it returns from the message, the owner of the owner-draw combo box, list box, or
menu item must fill out this member. The maximum height of a list box item is 255.
14 - Subitem ID
15-29 - Reserved
30-49 - Object data
50-59 - integer representation of strings 50-59
60-99 - Reserved
Array of string values:
0 - Full text of item
1 - top
2-49 - Reserved
50-59 - strings extracted from Full text of item using delimiter char(3)
60-99 - Reserved
Array of double values (You can use union syntax). Values 0-3 is a rectangle in
the device context specified by the hDC member that defines the boundaries
of the control to be drawn. Windows automatically clips anything the owner draws
in the device context for combo boxes, list boxes, and buttons, but it does not
clip menu items. When drawing menu items, the owner must not draw outside the boundaries
of the rectangle:
0-49 - Reserved
50-59 - double representation of strings 50-59
60-99 - Reserved
Array of rectangles:
0 - window rect of control (undefined for menus)
1 - client rect of control (undefined for menus)
2-9 - Reserved
Specific predefine values by ControlType
ODT_BUTTON (4) Owner-drawn button
Integer 30 - result of method GetState /001/prog9ilh.htm
ODT_COMBOBOX (3) Owner-drawn combo box
String 0 - result of method GetLBText 008/prog4rxw.htm
String 1 - result of method GetWindowText 002/prog2a9g.htm
ODT_LISTBOX (2) Owner-drawn list box
String 0 - result of method GetText 019/prog1apg.htm
ODT_MENU (1) Owner-drawn menu
Integer 30 - Menu item type.
Integer 31 - Menu item state.
Integer 32 - Application-defined 16-bit value that identifies the menu item.
Integer 33 - Handle to the drop-down menu or submenu associated with the menu item. If the menu item is not an item that opens a drop-down menu or submenu, this member is NULL.
Integer 34 - Handle to the bitmap to display next to the item if it is selected. If this member is NULL, a default bitmap is used. If the MFT_RADIOCHECK type value is specified, the default bitmap is a bullet. Otherwise, it is a check mark.
Integer 35 - Handle to the bitmap to display next to the item if it is not selected. If this member is NULL, no bitmap is used.
Integer 36 - Application-defined value associated with the menu item.
Integer 37 - Content of the menu item. The meaning of this member depends on the value of fType.
Integer 38 - Length of the menu item text, in TCHARs.
Integer 39 - Handle to the bitmap to be displayed.
Integer 40 -
ODT_LISTVIEW (102) List view control
ODT_STATIC (5) Owner-drawn static control
String 0 - result of method GetWindowText 002/prog2a9g.htm
ODT_TAB (101) Tab control
String 0 - Item text
Integer 30 - Specifies the item's current state.
Integer 31 - Index in the tab control's image list, or -1 if there is no image for the tab.
Integer 32 - Application-defined data associated with the tab control item.
ODT_HEADER (100) Tab control
String 0 - Item text
String 1 - Item filter text
Integer 30 - Width or height of the item.
Integer 31 - Flags that specify the item's format.
Integer 32 - Application-defined item data.
Integer 33 - Zero-based index of an image within the image list. The specified image will be displayed in the header item in addition to any image specified in the hbm field.
Integer 34 - Order in which the item appears within the header control, from left to right. That is, the value for the far left item is 0. The value for the next item to the right is 1, and so on.