MicrosoftMicrosoftFoundationFoundationClassesClassesJerry BergJerry BergChiupinChiupin Chen ChenTzu Chun LiuTzu Chun LiuMFCMFCv1.0 Introduced in 1992 as a thin C++ wrapper aroundv1.0 Introduced in 1992 as a thin C++ wrapper aroundthe Windows C APIthe Windows C APIv9.0 provided with Visual Studio 2008 (not in Express)v9.0 provided with Visual Studio 2008 (not in Express)Provides a class library for developing desktopProvides a class library for developing desktopapplications on the Windows platformapplications on the Windows platform> 200 classes> 200 classesProvides an application framework calledProvides an application framework calledDocument/ViewDocument/ViewMFCMFCHighly integrated with Visual Studio to speedHighly integrated with Visual Studio to speeddevelopmentdevelopmentShowing its ageShowing its age.NET is a much cleaner, easier framework to live.NET is a much cleaner, easier framework to livewithwithDocument/View FrameworkDocument/View FrameworkMicrosoftMicrosoft’’s version of model-view-controllers version of model-view-controllerNotice however that there is no controller soundingNotice however that there is no controller soundingelement in the framework nameelement in the framework nameA standardized way of organizing and separatingA standardized way of organizing and separatingapplication data and the visual representation ofapplication data and the visual representation ofthat datathat dataDoc/View ServicesDoc/View ServicesMany available View classes:Many available View classes:TreeTreeText EditText EditListListFormFormSerialization of application data to a fileSerialization of application data to a fileGeneric notification system for updating views inGeneric notification system for updating views inresponse to changing application dataresponse to changing application dataDoc/View Participants (SDI)Doc/View Participants (SDI)CWinAppCDocumentTemplateCFrameWndCViewCDocumentCWinAppCWinAppWhere your initialization stuff goesWhere your initialization stuff goesEvery MFC application must have a single, globalEvery MFC application must have a single, globalinstance of a class derived from instance of a class derived from CWinAppCWinAppThe instance must be named The instance must be named ““theApptheApp””In order for In order for theApptheApp to do anything useful, the to do anything useful, thedeveloper must override the developer must override the CWinApp::InitInstanceCWinApp::InitInstancemethodmethodCFrameWndCFrameWndWhere your toolbars, menus, and status bars goWhere your toolbars, menus, and status bars goThe outermost window of the applicationThe outermost window of the applicationProvides a Provides a resizeableresizeable border, border, titlebartitlebarContains and sizes a Contains and sizes a CViewCView object objectCDocumentCDocument<<abstract>><<abstract>>Where your data goesWhere your data goesThe central location for application data (the The central location for application data (the ““ModelModel”” part of part ofMVC)MVC)Provides notification mechanism for updating attached Provides notification mechanism for updating attached CViewCViewobjects (Observer pattern)objects (Observer pattern)Provides Serialization (Writing/Reading data to/from file)Provides Serialization (Writing/Reading data to/from file)The Developer must subclass The Developer must subclass CDocumentCDocument and provide methods and provide methodsfor accessing datafor accessing dataCViewCView <<abstract>> <<abstract>>Where you display your dataWhere you display your dataThe The ““ViewView”” part of MVC part of MVCFills the client area of a Fills the client area of a CFrameWndCFrameWnd object objectResponsible for displaying data contained in aResponsible for displaying data contained in aCDocumentCDocument object objectA subclass must override the A subclass must override the CView::OnDrawCView::OnDraw method methodCDocTemplateCDocTemplate<<abstract>><<abstract>>The thing that creates all the other stuffThe thing that creates all the other stuffThe The ““ControllerController”” part of MVC? part of MVC?Creates the frame and document, and view objects and connectsCreates the frame and document, and view objects and connectsthem together when the user requests a new document or that anthem together when the user requests a new document or that anexisting document be loadedexisting document be loadedThere are 2 commonly used subclasses of There are 2 commonly used subclasses of CDocTemplateCDocTemplate::CSingleDocTemplateCSingleDocTemplate (for SDI apps like notepad) (for SDI apps like notepad)CMultiDocTemplateCMultiDocTemplate (for MDI apps like Visual Studio) (for MDI apps like Visual
View Full Document