WinAPI: Using Brushes
After Pen Objects we will discuss here Brushes that’s another type of object which is associated with a Device Context. While Pens are used by Windows to draw lines, Brushes are objects that are used to fill the area enclosed within bound regions as ellipse, rectangle, polygons or paths.
Brushes are basically bitmaps of 8×8 pixels which are tiled to fill the bound space clipping itself to ensure that they don’t flow outside the region. Depending on how the 8×8 pixel is defined the brushes are classified as :
1. Solid Brushes - These types of brushes contain all the 64 pixels (8x
of the same color.
2. Hatch Brushes - These are the 6 predefined (by GDI) brushes to draw Horizontal, Vertical, Diagonal (Forward & Backward) and Cross (straight & Diagonal) hatches.
3. Pattern Brushes - These are the custom brushes created by application defined bitmaps or device independent bitmaps. While in Windows 95 the brushes created were strictly 8×8 pixels ignoring other pixels, Windows 98 and above support creating Pattern brushes larger than 8×8 pixels depending on the size of bitmap used to create the brush.
4. Stock Brushes - These are the solid brushes predefined by the Graphics Device Interface (7 in nos.) and Windows Management Interface (21 in nos.)
A brush is defined as following type
Type LOGBRUSH
lbStyle As Long
lbColor As Long
lbHatch As Long
End Type
lbStyle - is the Brush Style specification which can take one of the values defined below:
Const BS_SOLID = 0 Const BS_NULL = 1 Const BS_HOLLOW = BS_NULL Const BS_HATCHED = 2 Const BS_PATTERN = 3 Const BS_DIBPATTERN = 5 Const BS_DIBPATTERNPT = 6 Const BS_PATTERN8X8 = 7 Const BS_DIBPATTERN8X8 = 8
lbColor - is the long value representing the color (calculated using RGB macro), if the style passed to the brush is either BS_SOLID or BS_HATCHED. If the style passed is BS_HOLLOW or BS_PATTERN this value is ignored. If the style passed is BS_DIBPATTERN then the value should be one of those defined below.
Const DIB_RGB_COLORS = 0 ' DIB explicitly defines RGB colors Const DIB_PAL_COLORS = 1 ' DIB contains palette indices
lbHatch - If the style passed to the brush is BS_HATCHED, this value is one of the constants defined below. If the style passed is BS_SOLID or BS_HOLLOW this value is ignored. If the style passed is BS_PATTERN this value id the handle to the bitmap that defines the pattern. If the style passed is BS_DIBPATTERN this value is handle to the packed DIB.
Const HS_HORIZONTAL = 0 ' ----- Const HS_VERTICAL = 1 ' ||||| Const HS_FDIAGONAL = 2 ' \\\\\\\\\\ Const HS_BDIAGONAL = 3 ' ///// Const HS_CROSS = 4 ' +++++ Const HS_DIAGCROSS = 5 ' xxxxx

[...] already mentioned in previous post WinAPI: Using Brushes, 21 pre-defined stock brushes are maintained by the Window Management interface (User32.dll). These [...]
Pingback by Getting Stock Brushes « Jalaj — March 1, 2007 @ 4:22 am
[...] WinAPI, Visual Basic, Application — Jalaj @ 5:53 am As already mentioned earlier in WinAPI: Using Brushes brushes are or generally 8×8 pixels (or larger for Pattern Brushes). When you issue a function [...]
Pingback by WinAPI : Shifting Brush Origin « Jalaj — March 2, 2007 @ 5:53 am
[...] navigation Stats « WinAPI: Using Brushes Getting Stock Brushes [...]
Pingback by Creating Solid and Hatch Brushes « Jalaj — March 30, 2007 @ 7:02 am