MFC Workshop: Intro to MFC - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

MFC Workshop: Intro to MFC

Description:

Eliminates a lot of the monotony of Windows programming. Written in C . Code reuse saves time ... Small amount of overhead for a class library. You can still ... – PowerPoint PPT presentation

Number of Views:164
Avg rating:3.0/5.0
Slides: 11
Provided by: joe653
Category:
Tags: mfc | intro | monotony | workshop

less

Transcript and Presenter's Notes

Title: MFC Workshop: Intro to MFC


1
MFC Workshop Intro to MFC
2
What is MFC?
  • Microsoft Foundation Classes
  • C wrappers to the Windows SDK
  • An application framework
  • A useful set of extensions

MFC
SDK
Windows
3
Why MFC?
  • Eliminates a lot of the monotony of Windows
    programming.
  • Written in C
  • Code reuse saves time
  • Relatively easy for C programmers to pick up
  • Most Windows objects act like C objects in MFC
  • Small amount of overhead for a class library
  • You can still access the SDK.
  • Cross-platform (sort of)

4
How to use MFC
  • Derive the from classes to add functionality.
  • Override base class members.
  • Add new members.
  • Some classes can be used directly.

5
The one and only CWinApp
  • Derived from CObject-gtCCmdTarget-gtCWinThread.
  • CObject serialization and runtime information
  • CCmdTarget allows message handling
  • CWinThread allow multithreading, the CWinApp
    object is the primary thread
  • Derive one class, and declare one instance per
    application.
  • Encompasses WinMain(), message pump, etc.

6
CWnd and CFrameWnd
  • Holds an HWND and all of the functions associated
    with it.
  • Hides the WndProc() and handles message routing.
  • CWnd is the base class for everything from
    CButton to CFrameWnd.
  • CFrameWnd is the class used as the main window in
    most applications.

7
Message Handling
  • In MFC the message pump and WndProc are hidden by
    a set of macros.
  • MFC messaging acts virtually without the
    overhead.
  • To add message routing put the following line in
    the class declaration, DECLARE_MESSAGE_MAP().
  • For every message you want to handle you have to
    add an entry to the message map.

8
CDC and CPaintDC
  • MFC device context classes.
  • Holds a device context handle, and wraps the SDK
    DC functions.
  • CPaintDC is used when responding to WM_PAINT
    messages.
  • CPaintDC encapsulates calls to BeginPaint and
    EndPaint in the constructor and destructor
    respectively.

9
Simple types and GDI classes
  • MFC does a very simple encapsulation of
    structures like RECT and POINT with classes like
    CRect and CPoint.
  • One of the most useful classes in MFC is CString.
  • Similar to a character array, with a handful of
    useful methods
  • All of the GDI structures have their own classes
  • creation and destruction is handled by C
  • can be used freely with the old structures

10
MFC References
  • Programming Windows With MFC
  • Jeff Prosise
  • Professional MFC with Visual C
  • Mike Blaszczak
  • MFC Internals
  • George Shepherd and Scot Wingo
  • http//www.codeguru.com
  • news microsoft.public.vc.mfc
  • MSDN Library
  • The code itself, \VC98\Mfc\Src
Write a Comment
User Comments (0)
About PowerShow.com