Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 7: GDI Accessories and Tools


A square is a rectangle whose sides are all equal. Therefore, to draw a square, when
specifying the arguments of the Rectangle() method, make sure that |x1 - x2| = |y1 - y2|.

Practical Learning: Drawing Rectangles


6.3.7 A Rectangle With Edges.....................................................................


The CDC class provides another function member you can use to draw a rectangle. This
time you can control how the edges of the rectangle would be drawn. The method used is
called DrawEdge and its syntax is:

BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags);

The lpRect argument is passed as a pointer to a RECT or CRect, which is the rectangle
that would be drawn.

The nEdge value specifies how the interior and the exterior of the edges of the rectangle
would be drawn. It can be a combination of the following constants:

Value Description
BDR_RAISEDINNER The interior edge will be raised
BDR_SUNKENINNER The interior edge will be sunken
BDR_RAISEDOUTER The exterior edge will be raised
BDR_SUNKENOUTER The exterior edge will be sunken

These values can be combined using the bitwise OR operator. On the other hand, you can
use the following constants instead:

Value Used For
EDGE_DUMP BDR_RAISEDOUTER | BDR_SUNKENINNER
EDGE_ETCHED BDR_SUNKENOUTER | BDR_RAISEDINNER
EDGE_RAISED BDR_RAISEDOUTER | BDR_RAISEDINNER
EDGE_SUNKEN BDR_SUNKENOUTER | BDR_SUNKENINNER
Free download pdf