C MFCs - PowerPoint PPT Presentation

About This Presentation
Title:

C MFCs

Description:

C++ MFCs CS 123/CS 231 MFC: Writing Applications for Windows Classes in MFC make up an application framework Framework defines the skeleton of an application and ... – PowerPoint PPT presentation

Number of Views:80
Avg rating:3.0/5.0
Slides: 13
Provided by: JohnPa173
Category:

less

Transcript and Presenter's Notes

Title: C MFCs


1
C MFCs
  • CS 123/CS 231

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

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

4
Tools
  • AppWizard creates files for starter application
  • Resource editors to design UI elements visually
  • Class Wizard to connect these elements to code
  • Class Library to implement application specific
    logic

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

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

7
Objects in a Running SDI Application

Application Object
Document Template
Main Frame Window
Document
Tool Bar
View
Status Bar
8
GUI Programming
  • Use 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
  • Use 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
  • Use Resource Editors to Create and Edit Resources
  • Create and edit menus, dialog boxes, custom
    controls, accelarator keys, bitmaps, icons,
    cursors,

11
Messages
  • Applications running windows are message driven
  • User actions and events cause Windows to send
    messages to windows in the program
  • Ex Mouse actions
  • mouse click sends WM_LBUTTONDOWN
  • release sends WM_LBUTTONUP

12
Messages
  • Large part of programming task is choosing which
    messages to map to which objects, and implement
    the mapping
  • Class Wizard will create empty message handler
    member functions
  • Use source editor to implement the body of the
    handler
Write a Comment
User Comments (0)
About PowerShow.com