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 data structure that contains these attributes is called the DC data block.
Table 2.1 lists the default device-context attributes and the GDI functions that affect or use these attributes:
Table 2.1 Default Device-Context Attributes and Related GDI Functions
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 | ExcludeClipRect IntersectClipRect OffsetClipRgn SelectClipRgn |
Color palette | DEFAULT_PALETTE | CreatePalette RealizePalette SelectPalette |
Current pen position | (0,0) | MoveTo |
Drawing mode | R2_COPYPEN | SetROP2 |
Font | SYSTEM_FONT | CreateFont CreateFontIndirect SelectObject |
Table 2.1 Default Device-Context Attributes and Related GDI Functions (continued)
Attribute | Default | GDI Functions |
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 |
, |