A Windows application can use any of three tools when it creates output: a bitmap, a brush, or a pen. An application can use the pen and brush together, out-lining a region or object with the pen and filling the region's or object's interior with the brush. GDI allows the application to create pens with solid colors, bitmaps with solid or combination colors, and brushes with solid or combination colors. (The available colors and color combinations depend on the capabilities of the intended output device.)
There are seven predefined brushes available in GDI; an application selects any one of them by using the GetStockObject function. The following list describes these brushes:
Black
Dark-Gray
Gray
Hollow
Light-Gray
Null
White
There are six hatched brush patterns; an application can select any one of these patterns by using the CreateHatchBrush function. (A hatch line is a thin line that appears at regular intervals on a solid background.) The following list describes these hatch patterns:
Backward Diagonal
Cross
Diagonal Cross
Forward Diagonal
Horizontal
Vertical
Figure 2.2 shows each hatched brush pattern. A simple Windows application created this figure:
There are three predefined pens available in GDI; an application selects any one of them by using the GetStockObject function. The following list describes these pens:
Black
Null
White
In addition to selecting a stock pen, an application creates an original pen by using the GDI CreatePen function. This function allows the application to select one of six pen styles, a pen width, and a pen color (if the device has color capabilities). The pen style can be solid, dashed, dotted, a combination of dots and dashes, or null. The pen width is the number of logical units GDI maps to a certain number of pixels (this number is dependent on the current mapping mode if the pen is selected into a device context). The pen color is an RGB color value.
Figure 2.3 shows a variety of pen patterns obtained from calls to the CreatePen function. A simple Windows application created this figure: