Other Windows Classes

There are several other classes in the Microsoft Foundation Class Library that bring C++ syntax to Windows. These classes include CMenu, CPoint, CRect, and CSize.

The CMenu Class

A Windows menu is a data structure that associates user actions with WM_COMMAND messages. The CMenu class wraps this menu structure and provides a constructor for an empty menu. A menu's list of choices can be altered dynamically through member functions such as AppendMenu, InsertMenu, and DeleteMenu. The LoadMenu member function loads a menu object with a menu definition from a resource file.

You can attach a resource-based menu, identified by a string or resource ID, directly to a window (through the frame window's Create member function) without defining a CMenu object. Alternatively, the window SetMenu member function associates a CMenu object with the window.

The WM_COMMAND messages that result from menu activity must be processed by window class member functions that are declared through message- map entries.

The CPoint, CSize, and CRect Classes

CPoint and CSize are simple classes that define absolute and relative (x, y) points and provide some useful overloaded operators. The CRect class defines rectangular regions specified by the (left, top) and (right, bottom) coordinates. CPoint and CRect inherit from the Windows POINT and RECT structures.

Many Microsoft Foundation class functions take POINT structures or pointers to RECT structures as parameters. Because CPoint and CRect are derived from these structures, the compiler can accept objects in place of structure instances.