MFCThe Microsoft Foundation Class Library' - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

MFCThe Microsoft Foundation Class Library'

Description:

Most definitions will tell you that the MFC library is the class library for ... The term reuse in theory equates to 'makes development easier! ... – PowerPoint PPT presentation

Number of Views:120
Avg rating:3.0/5.0
Slides: 23
Provided by: ton143
Category:

less

Transcript and Presenter's Notes

Title: MFCThe Microsoft Foundation Class Library'


1
MFC The Microsoft Foundation Class Library.
  • MFC -1

2
So what is this MFC Library?
  • Most definitions will tell you that the MFC
    library is the class library for development of
    Microsoft ? Windows applications.
  • So what is a class library?
  • A "class library" is a set of standard classes
    (including properties and methods) for use in C
    program development.

3
System Development?
  • Although MFC was initially designed for
    application development.
  • System Development is greatly simplified
  • We need MFC to perform development for OLE and
    ActiveX in a realistic timescale!

4
Justification for Use
  • " they allow program developers to use some one
    else's code "
  • The term reuse in theory equates to "makes
    development easier!"
  • "MFC allows program developers to simplify the
    task of development of applications for windows
    in C, both by reuse of standard classes and by
    building basic skeleton code. "

5
Why Use it ?
  • The answer to this question lies in the idea
  • MFC offer a standard set of classes to build the
    basic elements of a windows application
  • it also includes the so called framework that
    builds a skeleton application.
  • This framework takes away the tedium of the
    standard aspects of windows programming i.e.
    WinMain(..) and the basic WinProc(...).

6
The Advantages
  • Having a standard set of classes.
  • to use the so called Class Wizards
  • to assist in the basic framework development and
    also to act as a CASE tool as new methods data
    etc., are added to standard classes.

7
An Example
  • Using the application wizard you can specify a
    base system design including
  • Multiple or single Document interfaces
  • Tool Bars
  • Status Bar
  • Extensions on data manipulation
  • Extensions to OLE design both container and server

8
MFC Evolution
  • It is important to look at the evolution of this
    particular class library.
  • Originally MFC was no more than some very simple
    wrapper functionality around the basic window API
    calls.
  • Now it reduces the complexity of API extensions
    such as MAPI,TAPI, OLE etc.

9

10
CObject
  • Serialisation the ability to load and save the
    object to /from structured permanent storage
  • Runtime Class Information the class name its
    position in the hierarchy can be extracted at run
    time.

11
CObject
  • Diagnostic Output ability if in debug mode to
    use trace info in debug window
  • Compatibility all objects must be a member of
    the MFC collection itself.

12
Library itself can be broadly categorised into
  • General purpose strings files, exceptions
    date/time and rectangles
  • Visual Objects windows, device context, GDI
    functions and dialogues.
  • Application architecture applications,
    documents (the data), views (on the data).
  • Collections lists arrays etc.

13
Library itself can be broadly categorised into
  • OLE specific functionality
  • ODBC specific functionality.

14
Message Maps
  • Each class that can receive messages or commands
    has its own "message map."
  • The class uses message maps to connect messages
    and commands to their handler functions.

15
A Typical message Map will have the form
  • BEGIN_MESSAGE_MAP(CMyView, CView)
  • //AFX_MSG_MAP (CMyView)
  • ON_WM_MOUSE ACTIVATE()
  • ON_COMMAND
  • (ID_EDIT_CLEAR_ALL, OnEditClearAll)
  • ON_UPDATE_COMMAND_UI
  • (ID_EDIT_CLEAR_ALL, OnUpdateEditClearAll)
  • //AFX_MSG_MAP

16
CWinApp
  • CWinApp class is the base class from which you
    always derive a windows application / system
    object.
  • Each application that uses the MFC classes can
    only contain one object derived from CWinApp.
  • CWinApp is declared at the global level.

17
CWnd
  • CWnd class provides the base functionality of all
    window classes.
  • A CWnd object is distinct from a Windows window,
    but the two are tightly linked.
  • The CWnd class and the message-map mechanism hide
    the WndProc function.

18
CPaintDC
  • The CPaintDC class is a device-context class
    derived from CDC..
  • The CDC class defines a class of device-context
    objects. All drawing is accomplished through the
    member functions of a CDC object.
  • Although this encapsulation aids readability it
    offers very little improvement on the basic GDI
    in the native API's.

19
Document /Views
  • Up to this point looking at the classes that are
    the basis of an application MFC can still be
    considered simply as wrappers for C around the
    basic 'C' API calls.
  • CWinApp offers the control of the application.
  • Start-up Execution Termination

20
Document /Views
  • The concept of documents and views builds this
    into a framework.
  • The CDocument class provides the basic
    functionality for user-defined document classes.
  • Users interact with a document through the CView
    object(s) associated with it.

21
CFrameWnd
  • The CFrameWnd class provides the functionality of
    a Windows single document interface (SDI)
    overlapped or pop-up frame window, along with
    members for managing the window.
  • It is within these CFrameWnd that we will
    normally derive the CView onto our CDocument data.

22
Some Typical Structures
Write a Comment
User Comments (0)
About PowerShow.com