The CDC
class provides a series of drawing functions that
correspond to Windows GDI drawing functions. Basic
drawing
functions include those that draw various (straight and curved)
lines and those that draw shapes.
Many line
drawing functions make use of the concept of the current
position in the device context. The current position is a
pair of coordinates that usually represents the endpoint
of the last drawing operation. The current position can be
set using the MoveTo member function and can be retrieved
using the GetCurrentPosition member function.
Line drawing
functions use the current pen for drawing the line. To
draw a straight line, use the MoveTo and
LineTo member
functions. To draw an elliptical arc, use the Arc or
ArcTo
functions. The direction of the arc can be controlled
using the SetArcDirection member function; (use
GetArcDirection to retrieve the current setting).
The Polyline
and PolylineTo functions can be used to draw a series of
connected line segments;
PolyPolyline is a function to
draw several polylines in a single operation. Windows can
also draw BŽzier curves; use the
PolyBezier or
PolyBezierTo member functions. Finally, a series of line
segments and BŽzier curves can be drawn in a single
operation using PolyDraw.
Shape
functions include Rectangle, RoundRect, Ellipse, Chord,
Pie, and Polygon. The shapes generated by these functions
are shown in Figure 4. One additional function,
PolyPolygon, enables the drawing of multiple polygons in a
single operation.
4. Some basic shapes.
The PaintRgn
function draws a region using the current brush. The
DrawFocusRect function is used to draw a rectangle around
an object to indicate that the object has the focus. The
focus rectangle is drawn using the exclusive OR logical
function, so calling DrawFocusRect for the second time
effectively removes the focus rectangle. Note that if you
scroll an area containing a focus rectangle, it is
necessary to remove the focus rectangle first, scroll the
area, and then redraw the focus rectangle.
MFC
Example
Note:
UCanCode Advance E-XD++
CAD Drawing and Printing Solution
Source Code Solution for C/C++, .NET V2025 is released!
Contact UCanCode Software
To buy the source code or learn more about with: