2.9.2 Pen Styles, Colors, Widths

If an application draws lines and does not create a new pen, GDI uses the default pen. This pen is black and is one pixel wide when the mapping mode is MM_TEXT. An application can create a new pen of a different width, style, and color by using the CreatePen function. The new color is dependent on the color capabilities of the output device. The new style can be solid, dotted, dashed, or a combination of dotted and dashed. Once an application creates a new pen, it can select it into a display context by using the SelectObject function.

Figure 2.8 shows simple line output created by the LineTo and MoveTo functions. The application created the rectangle on the left by using a styled pen and the rectangle on the right by using a solid pen: