Graphic Methods

These methods deal with drawing graphics within the device context of a window. See GetWindowDC, GetDC, and GetButtonDC for information on how to retrieve a device context.

CreateBrush

>>-aDialogControl~CreateBrush(--color--+-----------------+--)--><
                                       +-,brushSpecifier-+


The CreateBrush method creates a color brush or a bitmap brush. It returns the handle to a brush object. To remove the brush, use DeleteObject. The brush is used to fill rectangles.

Arguments:

The arguments are:

color

The color number. For a list of color numbers, refer to Definition of Terms.

brushSpecifier

The name of a bitmap file or one of the following keywords to create a hatched brush:

UPDIAGONAL

A 45-degree upward, left-to-right hatch

CROSS

A horizontal and vertical crosshatch

DIAGCROSS

A 45-degree crosshatch

DOWNDIAGONAL

A 45-degree downward, left-to-right hatch

HORIZONTAL

A horizontal hatch

VERTICAL

A vertical hatch

If CreateBrush is sent to a dialog object (subclass of ResDialog), brushSpecifier can also be an integer resource ID for a bitmap stored in the DLL that also stores the resource.

If this argument is omitted, a solid brush with the specified color is created.

CreatePen

                              +-1-----+
>>-aDialogControl~CreatePen(--+-------+--,--+----------------------+--,-->
                              +-width-+     |    +-SOLID------+    |
                                            +-"--+-DASH-------+--"-+
                                                 +-DOT--------+
                                                 +-DASHDOT----+
                                                 +-DASHDOTDOT-+
                                                 +-NULL-------+

   +-0-----+
>--+-------+--)---------------------------------------------------------><
   +-color-+


The CreatePen method creates a pen in the specified color and style. It returns the handle to a pen object. To remove the pen, use DeleteObject.

Arguments:

The arguments are:

width

The width of the lines that the pen will draw. If omitted, 1 is used as default.

style

One of the keywords listed in the syntax diagram. Values other than SOLID or NULL have no effect on pens with a width greater than 1. SOLID is the default.

color

The color number of the pen. If omitted, 0 is used as default. For a list of color numbers, refer to Definition of Terms.

Example:

The following example creates a dotted pen object with a width of 1:

hPen = MyDialog~CreatePen(1, "DOT", 13)

ObjectToDC

>>-aDialogControl~ObjectToDC(--dc--,--obj--)-------------------><


The ObjectToDC method loads a graphic object, namely a pen or a brush, into a device context. Subsequent lines, rectangles, and arcs are drawn using the pen and brush.

Arguments:

The arguments are:

dc

The device context.

obj

The object: a pen or a brush.

Return value:

The handle of the previous active pen or brush. It can be used to restore the previous environment.

Example:

The following example activates a pen for drawing:

dc = MyBaseDialog~GetDC
hpen = MyDialog~CreatePen(2, "SOLID", 4)
MyDialog~ObjectToDC(dc,hpen)
... /* do lines, rectangles, ... */
MyDialog~deleteObject(hpen)

DeleteObject

>>-aDialogControl~DeleteObject(--obj--)------------------------><


The DeleteObject method deletes a graphic object, namely a pen or a brush. See CreatePen and CreateBrush for information on how to get the handle of a pen or brush.

Arguments:

The only argument is:

obj

The handle of a pen or brush.