The Internet Encyclopedia (Volume 3)

(coco) #1

P1: 50


Mayfield WL040/Bidgoli-Vol III-Ch-52 June 23, 2003 16:35 Char Count= 0


THEMICROSOFTFOUNDATIONCLASSLIBRARY 637

Figure 2: The dialog editor.

The AppWizard and the ClassWizard
The AppWizard is an application framework generator.
That is, its function is to generate working, skeletal
GUI applications. The developer is prompted through a
sequence of wizard dialog boxes that present choices re-
lating to menu items, toolbars, database support, and
other commonly required application components and
decisions. When the AppWizard has completed its inter-
view of the programmer, it creates a Windows GUI ap-
plication that embodies the requested features. That ap-
plication can be compiled and run without the developer
writing a single line of code. However, the skeletal appli-
cation does not really do much; it is up to the programmer
to customize the application to fulfill its functionality.
The ClassWizard is a tool that works hand in hand with
the AppWizard. The function of the ClassWizard is to help
the developer create new classes, especially those derived
from MFC classes. The ClassWizard generates files that
contain the class interface and skeletal method imple-
mentations. The ClassWizard also takes the tedium out
of defining and “wiring” Windows message handling rou-
tines and managing data members related to Windows
controls. For example, one can use the ClassWizard to de-
fine the effect of clicking a mouse button in a particular
area of a window.

THE MICROSOFT FOUNDATION
CLASS LIBRARY
MFC Overview
The MFC library of Visual C++ is a robust collection of
classes that support many areas of the Windows API (ap-
plication program interface). These include such things as
windows, dialog controls, databases and record sets, and
Internet programming. There are numerous books that

provide extensive tutorial and reference coverage of MFC
programming in Visual C++ (e.g. Brain & Lovette, 1999;
Kruglinski et al., 1998; and White, 1999).
MFC is a strange hybrid of object-oriented and
older technologies. One of its greatest weaknesses (and
strengths) is its backward-compatibility to the Mi-
crosoft SDK (Software Development Kit), the non-object-
oriented predecessor of MFC. To make MFC work with
SDK legacy code, many non-object-oriented compromises
were required in MFC. This makes MFC a sometimes con-
fusing and frustrating patchwork of both traditional and
object-oriented approaches.
Pointers to MFC objects are used commonly through-
out Windows programming, so many of the methods
found in MFC classes are defined as virtual functions. For
example, theCButtonclass, which represents a dialog
pushbutton, can be instantiated directly. But the devel-
oper might want to control how some buttons will be ap-
pear when drawn. The programmer derives a new class
fromCButtonand implements in itDrawItem, a virtual
function also defined inCButton. Through the miracle
of virtual functions and pointers, the appropriate imple-
mentation ofDrawItemwill be called for all buttons.
Some MFC classes are abstract, requiring the devel-
oper create their own customized versions of the classes.
Examples of MFC abstract classes are the document and
view classes.

The Document/View Architecture
Many MFC applications are written using the docu-
ment/view architectureas defined by Microsoft. An appli-
cation that implements the document/view architecture
has at its core instances of classes that are derived from
four MFC classes:CWinApp,CFrameWnd,CDocument, and
CView. The messaging relationship among the instances
of these classes is shown in Figure 3.
Free download pdf