2.1.2 Device-Context Attributes

Device-context attributes describe selected drawing objects (pens and brushes), the selected font and its color, the way in which objects are drawn (or mapped) to the device, the area on the device available for output (clipping region), and other important information. The structure that contains the device-context attributes is called the device-context data block. The default attributes and the GDI functions that affect or use them are as follows.

Attribute Default GDI functions

Background color White SetBkColor
Background mode OPAQUE SetBkMode
Bitmap No default CreateBitmap CreateBitmapIndirect CreateCompatibleBitmap SelectObject
Brush WHITE_BRUSH CreateBrushIndirect CreateDIBPatternBrush CreateHatchBrush CreatePatternBrush CreateSolidBrush SelectObject
Brush origin (0,0) SetBrushOrg UnrealizeObject
Clipping region Display surface CreateEllipticRgn CreateEllipticRgnIndirect CreatePolygonRgn CreatePolyPolygonRgn CreateRectRgn CreateRoundRectRgn ExcludeClipRect IntersectClipRect OffsetClipRgn SelectClipRgn
Color palette DEFAULT_PALETTE CreatePalette RealizePalette SelectPalette UnrealizeObject
Current pen position (0,0) LineTo MoveTo
Drawing mode R2_COPYPEN SetROP2
Font SYSTEM_FONT CreateFont CreateFontIndirect SelectObject
Intercharacter spacing 0 SetTextCharacterExtra
Mapping mode MM_TEXT SetMapMode
Pen BLACK_PEN CreatePen CreatePenIndirect SelectObject
Polygon-filling mode ALTERNATE SetPolyFillMode
Stretching mode BLACKONWHITE SetStretchBltMode
Text color Black SetTextColor
Viewport extent (1,1) SetViewportExt
Viewport origin (0,0) SetViewportOrg
Window extent (1,1) SetWindowExt
Window origin (0,0) SetWindowOrg