1 / 10

MFC Workshop: Intro to MFC

MFC Workshop: Intro to MFC. What is MFC?. Microsoft Foundation Classes C++ wrappers to the Windows SDK An application framework A useful set of extensions. MFC. SDK. Windows. Why MFC?. Eliminates a lot of the monotony of Windows programming. Written in C++ Code reuse saves time

laurel
Download Presentation

MFC Workshop: Intro to MFC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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->CCmdTarget->CWinThread. • 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

More Related