Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microsoft Foundation Classes

Similar presentations


Presentation on theme: "Microsoft Foundation Classes"— Presentation transcript:

1 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

2 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

3 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); case Event_ButtonPush; theApp.handleButtonPush(e); //... other events;

4 Event loop example – cont.
default: ignoreEvent(e); break; }

5 code generator for MFC AppWizard ClassWizard
create project with MFC AppWizard consists of headers (.h files), implementation files (.cpp files), graphics resource file (.rc files), etc… ClassWizard

6 Document/View architecture
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

7 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

8 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

9 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


Download ppt "Microsoft Foundation Classes"

Similar presentations


Ads by Google