Defines a class of device-context objects.
Constructs a CDC object.
Terminates the current print job, erasing everything the application has written to the device since the last call of the StartDoc member function.
Closes and discards any paths in the device context.
Copies the comment from a buffer into a specified enhanced-format metafile.
Displays bitmaps that have transparent or semitransparent pixels.
Draws a line segment and an arc, and moves the current position to the ending point of the arc.
Draws an elliptical arc.
Draws an elliptical arc. This function is similar to Arc, except that the current position is updated.
Attaches a Windows device context to this CDC object.
Opens a path bracket in the device context.
Copies a bitmap from a specified device context.
Draws a chord (a closed figure bounded by the intersection of an ellipse and a line segment).
Closes an open figure in a path.
Creates a memory-device context that is compatible with another device context. You can use it to prepare images in memory.
Creates a device context for a specific device.
Creates an information context for a specific device. This provides a fast way to get information about the device without creating a device context.
Deletes the Windows device context associated with this CDC object.
Called by the CWinApp idle-time handler to delete any temporary CDC object created by FromHandle. Also detaches the device context.
Detaches the Windows device context from this CDC object.
Converts device units into HIMETRIC units.
Converts device units into logical units.
Draws a three-dimensional rectangle.
Erases and redraws a rectangle as it is dragged.
Draws the edges of a rectangle.
Accesses drawing capabilities of a video display that are not directly available through the graphics device interface (GDI).
Draws a rectangle in the style used to indicate focus.
Draw a frame control.
Draws an icon.
Displays an image and applies a visual effect to indicate a state.
Draws formatted text in the specified rectangle.
Draws formatted text in the specified rectangle using additional formats.
Draws an ellipse.
Ends a print job started by the StartDoc member function.
Informs the device driver that a page is ending.
Closes a path bracket and selects the path defined by the bracket into the device context.
Enumerates the pens and brushes available in a device context.
Allows applications to access facilities that are not directly available from a particular device through GDI. Also allows access to Windows escape functions. Escape calls made by an application are translated and sent to the device driver.
Creates a new clipping region that consists of the existing clipping region minus the specified rectangle.
Prevents drawing within invalid areas of a window by excluding an updated region in the window from a clipping region.
Fills an area with the current brush. Provides more flexibility than the CDC::FloodFill member function.
Writes a character string within a rectangular region using the currently selected font.
Closes any open figures in the current path and fills the path's interior by using the current brush and polygon-filling mode.
Fills a given rectangle by using a specific brush.
Fills a specific region with the specified brush.
Fills a rectangle with a solid color.
Transforms any curves in the path selected into the current device context, and turns each curve into a sequence of lines.
Fills an area with the current brush.
Draws a border around a rectangle.
Draws a border around a specific region using a brush.
Returns a pointer to a CDC object when given a handle to a device context. If a CDC object is not attached to the handle, a temporary CDC object is created and attached.
Returns the current arc direction for the device context.
Retrieves the setting for the current aspect-ratio filter.
Retrieves the current background color.
Retrieves the background mode.
Returns the current accumulated bounding rectangle for the specified device context.
Retrieves the origin of the current brush.
Retrieves the widths, in logical units, of consecutive characters in a given range from the current font.
Retrieves the widths, in logical units, of consecutive glyph indices in a specified range from the current TrueType font.
Retrieves various types of information on a character string.
Retrieves the fractional widths of consecutive characters in a given range from the current font.
Retrieves the widths, in logical coordinates, of consecutive glyph indices in a specified range from the current font.
Retrieves the dimensions of the tightest bounding rectangle around the current clipping boundary.
Retrieves the color adjustment values for the device context.
Returns a pointer to the currently selected CBitmap object.
Returns a pointer to the currently selected CBrush object.
Returns a pointer to the currently selected CFont object.
Returns a pointer to the currently selected CPalette object.
Returns a pointer to the currently selected CPen object.
Retrieves the current position of the pen (in logical coordinates).
Retrieves the current brush color.
Retrieves the current pen color.
Retrieves a specified kind of device-specific information about a given display device's capabilities.
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.
Returns information about the currently selected font for the specified display context.
Retrieves the outline curve or bitmap for an outline character in the current font.
Retrieves the current graphics mode for the specified device context.
Retrieves a halftone brush.
Retrieves the character kerning pairs for the font that is currently selected in the specified device context.
Retrieves the layout of a device context (DC). The layout can be either left to right (default) or right to left (mirrored).
Retrieves the current mapping mode.
Returns the miter limit for the device context.
Retrieves the closest logical color to a specified logical color that the given device can represent.
Retrieves font metric information for TrueType fonts.
Retrieves the widths of individual characters in a consecutive group of characters from the current font using the output device context.
Computes the width and height of a character string on the output device context.
Computes the width and height of a line of text on the output device context using the current font to determine the dimensions.
Retrieves the metrics for the current font from the output device context.
Retrieves the coordinates defining the endpoints of lines and the control points of curves found in the path that is selected into the device context.
Retrieves the RGB color value of the pixel at the specified point.
Retrieves the current polygon-filling mode.
Retrieves the current drawing mode.
Returns CDC::m_hDC, the output device context.
Retrieves the current bitmap-stretching mode.
Computes the width and height of a character string on the attribute device context.
Retrieves the text-alignment flags.
Retrieves the current setting for the amount of intercharacter spacing.
Retrieves the current text color.
Computes the width and height of a line of text on the attribute device context using the current font to determine the dimensions.
Retrieves the number of characters in a specified string that will fit within a specified space and fills an array with the text extent for each of those characters.
Retrieves the width and height of the specified array of glyph indices.
Copies the typeface name of the current font into a buffer as a null-terminated string.
Retrieves the metrics for the current font from the attribute device context.
Retrieves the x- and y-extents of the viewport.
Retrieves the x- and y-coordinates of the viewport origin.
Returns the window associated with the display device context.
Retrieves the x- and y-extents of the associated window.
Retrieves the x- and y-coordinates of the origin of the associated window.
Retrieves the current world-space to page-space transformation.
Fills rectangle and triangle structures with a gradating color.
Draws dimmed (grayed) text at the given location.
Converts HIMETRIC units into device units.
Converts HIMETRIC units into logical units.
Creates a new clipping region by forming the intersection of the current region and a rectangle.
Inverts the contents of a rectangle.
Inverts the colors in a region.
Determines whether the device context is being used for printing.
Draws a line from the current position up to, but not including, a point.
Converts logical units into device units.
Converts logical units into HIMETRIC units.
Combines the color data for the source and destination bitmaps using the given mask and raster operation.
Changes the world transformation for a device context using the specified mode.
Moves the current position.
Moves the clipping region of the given device.
Modifies the viewport origin relative to the coordinates of the current viewport origin.
Modifies the window origin relative to the coordinates of the current window origin.
Fills a region with the selected brush.
Creates a bit pattern.
Draws a pie-shaped wedge.
Plays the contents of the specified metafile on the given device. The enhanced version of PlayMetaFile displays the picture stored in the given enhanced-format metafile. The metafile can be played any number of times.
Performs a bit-block transfer of the bits of color data from the specified rectangle in the source device context to the specified parallelogram in the given device context.
Draws one or more Bzier splines. The current position is neither used nor updated.
Draws one or more Bzier splines, and moves the current position to the ending point of the last Bzier spline.
Draws a set of line segments and Bzier splines. This function updates the current position.
Draws a polygon consisting of two or more points (vertices) connected by lines.
Draws a set of line segments connecting the specified points.
Draws one or more straight lines and moves the current position to the ending point of the last line.
Creates two or more polygons that are filled using the current polygon-filling mode. The polygons may be disjoint or they may overlap.
Draws multiple series of connected line segments. The current position is neither used nor updated by this function.
Specifies whether the given point is within the clipping region.
Maps palette entries in the current logical palette to the system palette.
Draws a rectangle using the current pen and fills it using the current brush.
Determines whether any part of the given rectangle lies within the clipping region.
Releases m_hAttribDC, the attribute device context.
Releases m_hDC, the output device context.
Updates the m_hAttribDC device context.
Restores the device context to a previous state saved with SaveDC.
Draws a rectangle with rounded corners using the current pen and filled using the current brush.
Saves the current state of the device context.
Modifies the viewport extent relative to the current values.
Modifies the window extents relative to the current values.
Scrolls a rectangle of bits horizontally and vertically.
Selects the current path as a clipping region for the device context, combining the new region with any existing clipping region by using the specified mode.
Combines the given region with the current clipping region by using the specified mode.
Selects a GDI drawing object such as a pen.
Selects the logical palette.
Selects one of the predefined stock pens, brushes, or fonts provided by Windows.
Sets a programmer-supplied callback function that Windows calls if a print job must be aborted.
Sets the drawing direction to be used for arc and rectangle functions.
Sets m_hAttribDC, the attribute device context.
Sets the current background color.
Sets the background mode.
Controls the accumulation of bounding-rectangle information for the specified device context.
Specifies the origin for the next brush selected into a device context.
Sets the color adjustment values for the device context using the specified values.
Sets the current brush color.
Sets the current pen color.
Sets the current graphics mode for the specified device context.
Changes the layout of a device context (DC).
Sets the current mapping mode.
Alters the algorithm that the font mapper uses when it maps logical fonts to physical fonts.
Sets the limit for the length of miter joins for the device context.
Sets m_hDC, the output device context.
Sets the pixel at the specified point to the closest approximation of the specified color.
Sets the pixel at the specified coordinates to the closest approximation of the specified color. SetPixelV is faster than SetPixel because it does not need to return the color value of the point actually painted.
Sets the polygon-filling mode.
Sets the current drawing mode.
Sets the bitmap-stretching mode.
Sets the text-alignment flags.
Sets the amount of intercharacter spacing.
Sets the text color.
Adds space to the break characters in a string.
Sets the x- and y-extents of the viewport.
Sets the viewport origin.
Sets the x- and y-extents of the associated window.
Sets the window origin of the device context.
Sets the current world-space to page-space transformation.
Informs the device driver that a new print job is starting.
Informs the device driver that a new page is starting.
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.
Closes any open figures in a path, strikes the outline of the path by using the current pen, and fills its interior by using the current brush.
Renders the specified path by using the current pen.
Writes a character string at a specified location, expanding tabs to the values specified in an array of tab-stop positions.
Writes a character string at a specified location using the currently selected font.
Transfers a bit-block of color data from the specified source device context into a destination device context, rendering a specified color transparent in the transfer.
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.
Redefines the current path as the area that would be painted if the path were stroked using the pen currently selected into the device context.
Retrieves the handle of the device context.
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 graphics device interface (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, and 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 that parallel Windows functions that use device contexts.
Under Windows 95/98, all screen coordinates are limited to 16 bits. Therefore, an int passed to a CDC member function must lie in the range –32768 to 32767.
For specific uses, the Microsoft Foundation Class Library provides several classes derived from CDC . CPaintDC encapsulates calls to BeginPaint and EndPaint. CClientDC manages a display context associated with a window's client area. CWindowDC manages a display context associated with an entire window, including its frame and controls. CMetaFileDC associates a device context with a metafile.
CDC provides two member functions, GetLayout and SetLayout, for reversing the layout of a device context, which does not inherit its layout from a window. Such right-to-left orientation is necessary for applications written for cultures, such as Arabic or Hebrew, where the character layout is not the European standard.
CDC contains two device contexts, m_hDC and m_hAttribDC, which, on creation of a CDC object, refer to the same device. CDC directs all output GDI calls to m_hDC and most attribute GDI calls to m_hAttribDC. (An example of an attribute call is GetTextColor, while SetTextColor is an output call.)
For example, the framework uses these two device contexts to implement a CMetaFileDC object that will send output to a metafile while reading attributes from a physical device. Print preview is implemented in the framework in a similar fashion. You can also use the two device contexts in a similar way in your application-specific code.
There are times when you may need text-metric information from both the m_hDC and m_hAttribDC device contexts. The following pairs of functions provide this capability:
For more information on CDC, see Device Contexts.