microsoft foundation classes

9
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

Upload: aradia

Post on 05-Jan-2016

40 views

Category:

Documents


3 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 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

Page 2: Microsoft Foundation Classes

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

Page 3: Microsoft Foundation Classes

Event loop examplewhile (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;

Page 4: Microsoft Foundation Classes

Event loop example – cont.

default:ignoreEvent(e);break;

}}

Page 5: Microsoft Foundation Classes

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

Page 6: Microsoft Foundation Classes

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

Page 7: Microsoft Foundation Classes

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

Page 8: Microsoft Foundation Classes

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

Page 9: Microsoft Foundation Classes

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