Use of NULL_PEN, NULL_BRUSH, and HOLLOW_BRUSH

ID: Q66532


The information in this article applies to:

GDI contains several "NULL" stock objects: NULL_BRUSH, HOLLOW_BRUSH, and NULL_PEN. These objects are defined in WINDOWS.H (16-bit SDK) or in WINGDI.H (32-bit SDK). These header files define HOLLOW_BRUSH as NULL_BRUSH, so they are the same objects.

Note that NULL_BRUSH and NULL_PEN are NOT identical to the value NULL. The value NULL is defined as 0 (zero) in WINDOWS.H and is not a valid stock object.

Many GDI functions use the current brush to fill interiors and the current pen to draw lines. In some cases, an application may not want to modify the areas normally affected by the pen or brush. Selecting a NULL_PEN or NULL_BRUSH into the device context tells GDI not to modify the normally affected areas. In short, "NULL_" objects do not draw anything.

For example, the Rectangle() function uses the current brush to fill the interior of the rectangle and the current pen to draw the border. If NULL_PEN is selected into the device context, no border is drawn. If NULL_BRUSH or HOLLOW_BRUSH is selected, the interior of the rectangle is not painted. If both NULL_PEN and NULL_BRUSH are selected, the rectangle will not be drawn.

Additional query words: 3.00 3.10 3.50 4.00 hollow win16sdk


Keywords          : 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: March 3, 1999