Document/View architectureMFC suppose two subtypes of document /view applications
single document interface (SDI)
multiple document interface (MDI)
classes generated by MFC AppWizard
CxxxApp (xxx : project name)
handle application initialization
the programmer often does not change this class
Microsoft Foundation Classes
Win32 Application Programming Interface (Win32 API)
thousands of C functions: graphics, networking, database, interapplication communications
Microsoft Foundation Class (MFC)
C++ library of classes that wrap the C function of Win32 API
Windows Programming in MFC
event-driven programming model
Graphical User Interface (GUI)
event
mouse click, push button, drag, system failure, …
event handler
the system queues up events and then dispatches them to procedures known as event handlers
callback procedure
initialization phase
Event loop example
while (theApp.isRunning()) {
Event e = nextEvent();
unsigned id = e.getId();
switch (id) {
case Event_SingleMouseClick(e);
theApp.handleSingleMouseClick(e);
break;
case Event_DoubleMouseClick(e);
theApp.handleDoubleMouseClick(e);
break;
case Event_ButtonPush;
theApp.handleButtonPush(e);
break;
//... other events;
VC++ has two main subtypes
document/view application
dialog-based application
document/view architecture
model
comprises the application’s data
view
the user’s interface to the model
controller
handle events generated through the application’s view
Document/View architecture
MFC suppose two subtypes of document /view applications
single document interface (SDI)
multiple document interface (MDI)
classes generated by MFC AppWizard
CxxxApp (xxx : project name)
handle application initialization
the programmer often does not change this class
classes generated by MFC AppWizard
CxxxDoc
represent application’s document (i.e., data)
add data and methods to this class
CxxxView
represent application’s view and controller
add callback functions to the class
CMainFrame
represent the framed windows used
often does not change this class
document serialization
serialize virtual method
to save an object in a standard binary format
serializing an object out (i.e., write it to a file)
serializing an object in (i.e., read it from a file)
sample application: document serialization p. 489
Comments