Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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


CSize();
CSize(int initCX, int initCY);
CSize(SIZE initSize);
CSize(POINT initPt);
CSize(DWORD dwSize);

The default constructor allows you to declare a CSize variable whose values are not yet
available. The constructor that takes two arguments allows you to provide the width and
the height to create a CSize variable. If you want another CSize or a SIZE variables, you
can use the CSize(SIZE initSize) constructor to assign its values to your variable. You
can use the coordinates of a POINT or a CPoint variable to create and initialize a CSize
variable. When we study the effects of the mouse, we will know you can use the
coordinates of the position of a mouse pointer. These coordinates can help you define a
CSize variable.

Besides the constructors, the CSize class is equipped with different methods that can be
used to perform various operations on CSize and SIZE objects. For example, you can
add two sizes to get a new size. You can also compare two sizes to find out whether they
are the same.

2.2.7 Windows Dimensions............................................................................


When a window displays, it can be identified on the screen by its location with regards to
the borders of the monitor. A window can also be identified by its width and height.
These characteristics are specified or controlled by the rect argument of the Create()
method. This argument is a rectangle that can be created through the Win32 RECT
structure or the MFC's CRect class. First, you must know how Microsoft Windows
represents a rectangle.

A rectangle is a geometric figure with four sides or borders: top, right, bottom, and left. A
window is also recognized as a rectangle. Therefore, it can be represented as follows:
Free download pdf