Pens

In Windows CE, a pen is a graphic object for drawing lines. Drawing applications use pens to draw freehand lines and straight lines. Computer-aided design (CAD) applications use pens to draw visible lines, section lines, center lines, and so on. Word processing and desktop publishing applications use pens to draw borders and rules. Spreadsheet applications use pens to designate trends in graphs and to outline bar graphs and pie charts.

Windows CE stock pens include the BLACK_PEN and the WHITE_PEN, which each draw a solid, 1-pixel-wide line in their respective color, and the NULL_PEN which does not draw. You obtain the stock pens with the GetStockObject function.

You use the CreatePen or CreatePenIndirect functions to create a custom pen with a unique color, width, or pen style.

The pen styles supported by Windows CE are described in the following table.

Pen style Description
PS_SOLID Draws a solid line.
PS_DASH Draws a dashed line.
PS_NULL Does not draw a line

Windows CE supports wide pens and dashed pens, but it does not support wide, dashed pens, dotted pens, inside frame pens, geometric pens or pen endcap styles. All Windows CE pens are cosmetic.

You can create a pen with a unique color by storing the red, green, blue (RGB) triplet that specifies the desired color in a COLORREF structure and passing this structure's address to the CreatePen or CreatePenIndirect function. In the case of CreatePenIndirect, the COLORREF pointer is actually incorporated into the LOGPEN structure, which is used by CreatePenIndirect.

Note The wide pen requires a lot of GDI computation. To improve the performance of a handwriting application, use a standard -sized pen whenever possible.