functions that operate on device contexts require that you
select a GDI object into the device context first. To
select a GDI object into a device context, use the
CDC::SelectObject member function. This member function
has several overloaded versions that enable you to select
an object of type CPen, CBrush, CFont, CBitmap, or CRgn
into the device context.
pen into a device context is required for functions that
draw lines. These include simple line drawing functions
(such as Line, Arc) as well as functions that
as the contour of shapes is drawn using the current pen.
brush is required when a shape (for example, Ellipse,
Rectangle) is drawn. The brush will be used to fill the
interior of the shape.
object of type CFont into a device context if you wish to
draw text using a specific font.
memory device contexts, you must select a CBitmap object
into them. The CBitmap object must represent either a
monochrome bitmap or a bitmap that is compatible with the
CRgn object into a device context sets the clipping region
of the device context to the specified region. Doing this
is equivalent to calling the CDC::SelectClipRgn member
situations, it is expected that when you are finished
using a device context, you restore its previous state
including any previous GDI object selections. There are
two ways of doing this. You can save the return value of
SelectObject (which is usually a pointer to a CPen, CBrush,
CFont, or CBitmap object representing the previous
selection) and use it in a subsequent call to SelectObject.
Alternatively, you can use the SaveDC and
functions. In either case, it is your responsibility to
delete any GDI objects you created once they are no longer
A variant of
SelectObject is SelectStockObject; this
function enables you to select a GDI stock object into the
UCanCode Advance E-XD++
CAD Drawing and Printing Solution
Source Code Solution for C/C++, .NET V2022 is released!
Contact UCanCode Software
To buy the source code or learn more about with: