Presentation is loading. Please wait.

Presentation is loading. Please wait.

C++ MFCs CS 123/CS 231. MFC: Writing Applications for Windows zClasses in MFC make up an application framework zFramework defines the skeleton of an application.

Similar presentations


Presentation on theme: "C++ MFCs CS 123/CS 231. MFC: Writing Applications for Windows zClasses in MFC make up an application framework zFramework defines the skeleton of an application."— Presentation transcript:

1 C++ MFCs CS 123/CS 231

2 MFC: Writing Applications for Windows zClasses in MFC make up an application framework zFramework defines the skeleton of an application and supplies standard user-interface implementation that can be placed on the skeleton zAdditional programming task: fill in the skeleton with things specific to your application

3 SDI and MDI zSingle Document Interface (SDI) Õallows only one open document frame window at a time zMultiple Document Interface (MDI) Õallows multiple document frame windows to be open in the same instance of an application

4 Tools zAppWizard creates files for starter application zResource editors to design UI elements visually zClass Wizard to connect these elements to code zClass Library to implement application specific logic

5 Document, Views and Framework zDocument – data object with which the user interacts in an editing session Õderived from CDocument zView – window object through which the user interacts with a document Õderived from CView zFrame Window – views are displayed inside document fram windows Õderived from CFrameWnd

6 Document, Views and Framework zDocument Template – orchestrates creation of documents, views, and frame windows Õderived from CDocTemplate Õcreates and manages all documents of 1 type zApplication Object – controls all of the objects above and specifies application behavior such as initialization and cleanup zThread Objects – for multithreaded application Õderived from CWinThread

7 Objects in a Running SDI Application Tool Bar View Status Bar Application Object Document Template Document Main Frame Window

8 GUI Programming zUse the AppWizard to create an MFC Application ÕFor project type, select MFC AppWizard (exe) ÕCreates files that contain the application, document, view, and frame window classes; standard resources, including menus and optional toolbar; other required windows files; optional.RTF file containing standard windows help topics

9 GUI Programming zUse ClassWizard to Manage Classes and Windows Messages ÕCreate handler functions for windows messages and commands ÕCreate and manage classes ÕCreate class member variables ÕCreate OLE Automation methods and properties ÕCreate database classes, etc

10 GUI Programming zUse Resource Editors to Create and Edit Resources ÕCreate and edit menus, dialog boxes, custom controls, accelarator keys, bitmaps, icons, cursors, …

11 Messages zApplications running windows are message driven zUser actions and events cause Windows to send messages to windows in the program zEx: Mouse actions Õmouse click sends WM_LBUTTONDOWN Õrelease sends WM_LBUTTONUP

12 Messages zLarge part of programming task is choosing which messages to map to which objects, and implement the mapping zClass Wizard will create empty message handler member functions zUse source editor to implement the body of the handler


Download ppt "C++ MFCs CS 123/CS 231. MFC: Writing Applications for Windows zClasses in MFC make up an application framework zFramework defines the skeleton of an application."

Similar presentations


Ads by Google