Microsoft Foundation Classes (mfc.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
class CDC
◄CObject►                                     ◄Up► ◄Contents► ◄Index► ◄Back►
──Microsoft Foundation Classes──────────────────────────────────────────────
 
  Description
 
  The CDC class defines a class of device-context objects. The CDC object
  provides member functions for working with a device context, such as a
  display or printer, as well as members for working with a display
  context associated with the client area of a window.
 
  Do all drawing through the member functions of a CDC object. The class
  provides member functions for device-context operations, working with
  drawing tools, type-safe GDI object selection, and working  with colors
  and palettes. It also provides member functions for getting and setting
  drawing attributes, mapping, working with the viewport, working with the
  window extent, converting coordinates, working with regions, clipping,
  drawing lines, drawing simple shapes, ellipses, and polygons. Member
  functions are also provided for drawing text, working with fonts, using
  printer escapes, scrolling, and playing metafiles.
 
  To use a CDC object, construct it, and then call its member functions,
  which parallel Windows functions that use device contexts or display
  contexts.
 
  For specific uses, the Microsoft Foundation Class Library provides
  several classes derived from CDC──in particular class CPaintDC, which
  encapsulates calls to BeginPaint and EndPaint. Class CClientDC manages a
  display context associated with a window's client area. Class CWindowDC
  manages a display context associated with an entire window, including
  its frame and controls. Class CMetaFileDC associates a device context
  associated with a metafile.
 
  CDC supports the Attach/Detach idiom for Windows handles described in
  ◄CWnd►.
 
  See Also
 
  ◄CPaintDC►, ◄CWindowDC►, ◄CClientDC►, ◄CMetaFileDC►
 
  Public Members
 
  Construction/Destruction
 
  ◄CDC►   Constructs a CDC object.
 
  ◄~CDC►   Destroys a CDC object.
 
  Initialization
 
  ◄CreateDC►             Creates a device context for a specific device.
 
  ◄CreateIC►             Creates an information context for a specific
                         device. This provides a fast way to get
                         information about the device without creating a
                         device context.
 
  ◄CreateCompatibleDC►   Creates a memory device context that is
                         compatible with another device context. You can
                         use it to prepare images in memory.
 
  ◄DeleteDC►             Deletes the Windows DC associated with this CDC
                         object.
 
  Device-Context Functions
 
  ◄GetDCOrg►        Obtains the final translation origin for the device
                    context.
 
  ◄SaveDC►          Saves the current state of the device context.
 
  ◄RestoreDC►       Restores the device context to a previous state saved
                    with SaveDC.
 
  ◄GetDeviceCaps►   Retrieves a specified kind of device-specific
                    information about a given display device's
                    capabilities.
 
  Drawing-Tool Functions
 
  ◄GetBrushOrg►   Retrieves the origin of the current brush.
 
  ◄SetBrushOrg►   Specifies the origin for the next brush selected into a
                  device context.
 
  ◄EnumObjects►   Enumerates the pens and brushes available in a device
                  context.
 
  Type-Safe Selection Helpers
 
  ◄SelectObject►        Selects a GDI drawing object, such as a pen.
 
  ◄SelectStockObject►   Selects one of the predefined stock pens, brushes,
                        or fonts provided by Windows.
 
  Color and Color Palette Functions
 
  ◄GetNearestColor►   Retrieves the closest logical color to a specified
                      logical color that the given device can represent.
 
  ◄SelectPalette►     Selects the logical palette.
 
  ◄RealizePalette►    Maps palette entries in the current logical palette
                      to the system palette.
 
  ◄UpdateColors►      Updates the client area of the device context by
                      matching the current colors in the client area to
                      the system palette on a pixel-by-pixel basis.
 
  Drawing-Attribute Functions
 
  ◄GetBkColor►          Retrieves the current background color.
 
  ◄SetBkColor►          Sets the current background color.
 
  ◄GetBkMode►           Retrieves the background mode.
 
  ◄SetBkMode►           Sets the background mode.
 
  ◄GetPolyFillMode►     Retrieves the current polygon-filling mode.
 
  ◄SetPolyFillMode►     Sets the polygon-filling mode.
 
  ◄GetROP2►             Retrieves the current drawing mode.
 
  ◄SetROP2►             Sets the current drawing mode.
 
  ◄GetStretchBltMode►   Retrieves the current bitmap-stretching mode.
 
  ◄SetStretchBltMode►   Sets the bitmap-stretching mode.
 
  ◄GetTextColor►        Retrieves the current text color.
 
  ◄SetTextColor►        Sets the text color.
 
  Mapping Functions
 
  ◄GetMapMode►          Retrieves the current mapping mode.
 
  ◄SetMapMode►          Sets the current mapping mode.
 
  ◄GetViewportOrg►      Retrieves the x- and y-coordinates of the viewport
                        origin.
 
  ◄SetViewportOrg►      Sets the viewport origin.
 
  ◄OffsetViewportOrg►   Modifies the viewport origin relative to the
                        coordinates of the current viewport origin.
 
  ◄GetViewportExt►      Retrieves the x- and y-extents of the viewport.
 
  ◄SetViewportExt►      Sets the x- and y-extents of the viewport.
 
  ◄ScaleViewportExt►    Modifies the viewport extent relative to the
                        current values.
 
  ◄GetWindowOrg►        Retrieves the x- and y-coordinates of the origin
                        of the associated window.
 
  ◄SetWindowOrg►        Sets the window origin of the device context.
 
  ◄OffsetWindowOrg►     Modifies the window origin relative to the
                        coordinates of the current window origin.
 
  ◄GetWindowExt►        Retrieves the x- and y-extents of the associated
                        window.
 
  ◄SetWindowExt►        Sets the x- and y-extents of the associated
                        window.
 
  ◄ScaleWindowExt►      Modifies the window extents relative to the
                        current values.
 
  Coordinate Functions
 
  ◄DPtoLP►   Converts device points or rectangles into logical points or
             rectangles.
 
  ◄LPtoDP►   Converts logical points or rectangles into device points or
             rectangles.
 
  Region Functions
 
  ◄FillRgn►     Fills a specific region with the specified brush.
 
  ◄FrameRgn►    Draws a border around a specific region using a brush.
 
  ◄InvertRgn►   Inverts the colors in a region.
 
  ◄PaintRgn►    Fills a region with the selected brush.
 
  Clipping Functions
 
  ◄GetClipBox►          Retrieves the dimensions of the tightest bounding
                        rectangle around the current clipping boundary.
 
  ◄SelectClipRgn►       Selects the given region as the current clipping
                        region.
 
  ◄ExcludeClipRect►     Creates a new clipping region that consists of the
                        existing clipping region minus the specified
                        rectangle.
 
  ◄ExcludeUpdateRgn►    Prevents drawing within invalid areas of a window
                        by excluding an updated region in the window from
                        a clipping region.
 
  ◄IntersectClipRect►   Creates a new clipping region by forming the
                        intersection of the current region and a
                        rectangle.
 
  ◄OffsetClipRgn►       Moves the clipping region of the given device.
 
  ◄PtVisible►           Specifies whether the given point is within the
                        clipping region.
 
  ◄RectVisible►         Determines whether any part of the given rectangle
                        lies within the clipping region.
 
  Line-Output Functions
 
  ◄GetCurrentPosition►   Retrieves the current position of the pen (in
                         logical coordinates).
 
  ◄MoveTo►               Moves the current position.
 
  ◄LineTo►               Draws a line from the current position up to, but
                         not including, a point.
 
  ◄Arc►                  Draws an elliptical arc.
 
  ◄Polyline►             Draws a set of line segments connecting the
                         specified points.
 
  Simple Drawing Functions
 
  ◄FillRect►     Fills a given rectangle by using a specific brush.
 
  ◄FrameRect►    Draws a border around a rectangle.
 
  ◄InvertRect►   Inverts the contents of a rectangle.
 
  ◄DrawIcon►     Draws an icon.
 
  Ellipse and Polygon Functions
 
  ◄Chord►           Draws a chord (a closed figure bounded by the
                    intersection of an ellipse and a line segment).
 
  ◄DrawFocusRect►   Draws a rectangle in the style used to indicate
                    focus.
 
  ◄Ellipse►         Draws an ellipse.
 
  ◄Pie►             Draws a pie-shaped wedge.
 
  ◄Polygon►         Draws a polygon consisting of two or more points
                    (vertices) connected by lines.
 
  ◄PolyPolygon►     Creates two or more polygons that are filled using the
                    current polygon-filling mode. The polygons may be
                    disjoint or they may overlap.
 
  ◄Rectangle►       Draws a rectangle using the current pen and filled
                    using the current brush.
 
  ◄RoundRect►       Draws a rectangle with rounded corners using the
                    current pen and filled using the current brush.
 
  Bitmap Functions
 
  ◄PatBlt►         Creates a bit pattern.
 
  ◄BitBlt►         Copies a bitmap from a specified device context.
 
  ◄StretchBlt►     Moves a bitmap from a source rectangle and device into
                   a destination rectangle, stretching or compressing the
                   bitmap if necessary to fit the dimensions of the
                   destination rectangle.
 
  ◄GetPixel►       Retrieves the RGB color value of the pixel at the
                   specified point.
 
  ◄SetPixel►       Sets the pixel at the specified point to the closest
                   approximation of the specified color.
 
  ◄FloodFill►      Fills an area with the current brush.
 
  ◄ExtFloodFill►   Fills an area with the current brush. Provides more
                   flexibility than the ◄FloodFill► member function.
 
  Text Functions
 
  ◄TextOut►                 Writes a character string at a specified
                            location, using the currently selected font.
 
  ◄ExtTextOut►              Writes a character string within a rectangular
                            region, using the currently selected font.
 
  ◄TabbedTextOut►           Writes a character string at a specified
                            location, expanding tabs to the values
                            specified in an array of tab-stop positions.
 
  ◄DrawText►                Draws formatted text in the specified
                            rectangle.
 
  ◄GetTextExtent►           Computes the width and height of a line of
                            text, using the current font to determine the
                            dimensions.
 
  ◄GetTabbedTextExtent►     Computes the width and height of a character
                            string.
 
  ◄GrayString►              Draws dimmed (gray) text at the given
                            location.
 
  ◄GetTextAlign►            Retrieves the text-alignment flags.
 
  ◄SetTextAlign►            Sets the text-alignment flags.
 
  ◄GetTextFace►             Copies the typeface name of the current font
                            into a buffer as a null-terminated string.
 
  ◄GetTextMetrics►          Retrieves the metrics for the current font.
 
  ◄SetTextJustification►    Adds space to the break characters in a
                            string.
 
  ◄GetTextCharacterExtra►   Retrieves the current setting for the amount
                            of intercharacter spacing.
 
  ◄SetTextCharacterExtra►   Sets the amount of intercharacter spacing.
 
  Font Functions
 
  ◄GetCharWidth►           Retrieves the widths of individual characters
                           in a consecutive group of characters from the
                           current font.
 
  ◄SetMapperFlags►         Alters the algorithm that the font mapper uses
                           when it maps logical fonts to physical fonts.
 
  ◄GetAspectRatioFilter►   Retrieves the setting for the current
                           aspect-ratio filter.
 
  Printer Escape Functions
 
  ◄Escape►         Allows applications to access facilities of a
                   particular device that are not directly available
                   through GDI. Escape calls made by an application are
                   translated and sent to the device driver.
 
  ◄StartDoc►       Informs the device driver that a new print job is
                   starting.
 
  ◄StartPage►      Informs the device driver that a new page is starting.
 
  ◄EndPage►        Informs the device driver that a page is ending.
 
  ◄SetAbortProc►   Sets a programmer-supplied callback function that
                   Windows calls if a print job must be aborted.
 
  ◄AbortDoc►       Terminates the current print job, erasing everything
                   the application has written to the device since the
                   last EndDoc escape.
 
  ◄EndDoc►         Ends a print job started by a StartDoc escape.
 
  Scrolling Functions
 
  ◄ScrollDC►   Scrolls a rectangle of bits horizontally and vertically.
 
  Metafile Functions
 
  ◄PlayMetaFile►   Plays the contents of the specified metafile on the
                   given device. The metafile can be played any number of
                   times.
 
  Windows 3.1 Functions
 
  ◄SetBoundsRect►           Controls the accumulation of
                            bounding-rectangle information for the
                            specified device context.
 
  ◄GetBoundsRect►           Returns the current accumulated bounding
                            rectangle for the specified device context.
 
  ◄StartDoc►                Starts a print job. For Windows version 3.1,
                            this function replaces the STARTDOC printer
                            escape.
 
  ◄QueryAbort►              Calls the ◄AbortProc► callback function for a
                            printing application and queries whether the
                            printing should be terminated.
 
  ◄GetCharABCWidths►        Retrieves the widths of consecutive characters
                            in a specified range from the current TrueType
                            font. The widths are returned in logical
                            units. This function succeeds only with
                            TrueType fonts.
 
  ◄GetFontData►             Retrieves font metric information from a
                            scalable font file. The information to
                            retrieve is identified by specifying an offset
                            into the font file and the length of the
                            information to return.
 
  ◄GetKerningPairs►         Retrieves the character kerning pairs for the
                            font that is currently selected in the
                            specified device context.
 
  ◄GetOutlineTextMetrics►   Retrieves font metric information for TrueType
                            fonts.
 
  ◄GetGlyphOutline►         Retrieves the outline curve or bitmap for an
                            outline character in the current font.
 
 
                                     -♦-