INF: Use of NULL_PEN, NULL_BRUSH, and HOLLOW_BRUSH

ID Number: Q66532

3.00

WINDOWS

Summary:

GDI contains several "NULL" stock objects: NULL_BRUSH, HOLLOW_BRUSH,

and NULL_PEN. In the Windows version 3.00 Software Development Kit

(SDK), WINDOWS.H defines HOLLOW_BRUSH as NULL_BRUSH, so they are the

identical object.

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.