In Windows CE, a brush is a graphic object for painting the interior of closed shapes. Drawing applications use brushes to paint shapes; word processing applications use brushes to paint rules; computer-aided design (CAD) applications use brushes to paint the interiors of cross-section views; and spreadsheet applications use brushes to paint graphs.
When you call one of the functions that create a brush, such as CreatePatternBrush, it returns a handle to a logical brush. When you select the logical brush into the device context with the SelectObject function, the device driver for the corresponding device creates the physical brush that will be used for painting.
When you call a painting function, GDI maps a pixel in the brush bitmap to the window origin of the client area. The window origin is the upper-left corner of the window's client area. The coordinates of the mapped pixel are called the brush origin. The default brush origin is the upper-left corner of the brush bitmap, at the coordinates (0, 0). You can use the SetBrushOrgEx function to change the location of the brush origin by a specified number of pixels. To make the changes effective, you must use the SelectObject function to select the modified brush.
Windows CE supports three types of logical brushes: stock brushes, solid brushes, and pattern brushes.
The seven types of stock brushes consist of the white brush, black brush, gray brush, light gray brush, dark gray brush, the null brush (which does not paint), and the hollow brush. You can use the GetStockObject function to select one of the stock brushes.
Windows CE maintains 21 stock brushes whose colors are used in window elements such as menus, scroll bars, and buttons. You can obtain a handle to a system stock brush with the GetSysColorBrush function. Furthermore, you can retrieve the color window element with the GetSysColor function, and set a color corresponding to a window element with the SetSysColors function.
A solid brush contains 64 pixels of the same color in an 8 pixel by 8 pixel square. You can call the CreateSolidBrush function to create a solid brush of a specified color. To paint with your solid brush, use SelectObject to select it into a specified device context.
You can create a pattern brush from an application-defined bitmap or a device-independent bitmap (DIB). To create a logical pattern brush, you must create a bitmap, and then call the CreatePatternBrush or CreateDIBPatternBrushPt function, supplying a handle that identifies the bitmap or DIB.
Windows CE does not support hatched brushes. However, you can achieve the effect of a hatched brush by creating a pattern brush with the desired hatch pattern using the CreateDIBPatternBrushPt function. You can create bitmaps of multiple sizes as well.