Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 2 Variables and Identifiers Visual C++ and MFC Fundamentals


This structure can be used to control the location of a window on a coordinate system. It
can also be used to control or specify the dimensions of a window. To use it, specify a
natural numeric value for each of its member variables and pass its variable as the rect
argument of the Create() method. Here is an example:

RECT Recto;

Recto.left = 100;
Recto.top = 120;
Recto.right = 620;
Recto.bottom = 540;

Create(NULL, "Windows Application", WS_OVERLAPPEDWINDOW, Recto);

Besides the Win32 RECT structure, the MFC provides an alternate way to represent a
rectangle on a window. This is done as follows:

Figure 33: Illustration of Window Location, Origin, and Size...............................................


Besides the left, top, right, and bottom measurements, a window is also recognized for its
width and its height. The width is the distance from the left to the right borders of a
rectangle. The height is the distance from the top to the bottom borders of a rectangle. To
recognize all these measures, the Microsoft Foundation Classes library provides a class
called CRect. This class provides various constructors for almost any way of
representing a rectangle. The CRect class provides the following constructors:
Free download pdf