Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 15: Fundamental Controls


The controls you add are confined to the client area offered by the parent window. After
visually adding a control to a parent window, it assumes a location and takes some
dimensions in this area. The origin of the rectangular client area is on the upper-left
corner of the parent window. The horizontal measurements move from the origin to the
right. The vertical measurements move from the origin to the bottom:

A control can be added only in the client area. To find out how much room a parent
window is making available to its children, that is, to get the dimensions (and screen
location) of the client area, you can call the CWnd::GetClientRect() member function.
Its syntax is:

void GetClientRect(LPRECT lpRect) const;

This member function takes as argument a RECT or CRect variable and stores the
location and dimension of the client rectangular area in it. In the following example, the
Free download pdf