1 / 9

Microsoft Foundation Classes

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.

aradia
Download Presentation

Microsoft Foundation Classes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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

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

  5. code generator for MFC • AppWizard • 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

More Related