145. MFC Windows
Programming for C++ Programmers
Rev. 6.2
This course is a very thorough presentation of Windows programming
via an object oriented approach using Visual C++ and the Microsoft Foundation
Class Library. The course consists of two modules.
The first module covers the essential elements of Windows
programming via an object oriented approach using Visual C++ and the MFC. The
basic structure of Windows programs and the MFC encapsulation is explained, and
then the power of MFC and the Visual C++ development environment is exploited
to build working Windows applications. The student will gain experience using
the Visual Studio, AppWizard, and ClassWizard. Fundamental Windows programming
topics are covered, including the mouse, keyboard, Graphics Device Interface,
controls, dialog boxes, menus, toolbars and status bars. The document/view
architecture is introduced. A fundamental approach is taken to understanding
MFC, building programs by making direct calls to MFC before using automated
tools.
The second module covers intermediate topics in MFC Windows
programming. Mouse programming techniques are discussed, including
rubberbanding and drag and drop. Additional topics in dialog boxes are covered,
including the common dialogs and programming modeless dialogs. Fonts are
discussed. MFC services are covered, including runtime type information,
serialization, diagnostics and exceptions. The MFC collection classes are
surveyed, including the template collection classes. Document/view architecture
is presented in greater depth, including MDI and the role of document templates
in dealing with multiple view types and multiple document types. The student is
introduced to a number of advanced topics, including the MFC database classes,
the Win32 common controls, and DLLs. OLE and ActiveX are introduced, including
use of ActiveX controls.
Extensive programming examples and exercises are provided using
Visual C++ 6.0. Besides doing standalone exercises, during the course the
student will develop several cumulative Windows applications. A disk is
provided containing all the examples and laboratory exercises in the course.
LEARNING OBJECTIVES
·
Gain an in-depth understanding of the Microsoft
Foundation Class Library
·
Learn use of the Visual C++ development tools, Visual
Studio, AppWizard, and ClassWizard
·
Acquire a working knowledge of Windows programming
using Visual C++ and MFC
·
Learn how to implement database programs using the MFC
encapsulation of ODBC
·
Become introduced to ActiveX and to important Win32
topics including the common controls and DLLs
Course Duration: 5
days
Prerequisites:
Knowledge of C++. Previous SDK Windows programming experience is not
required.
Module 1. MFC Windows Programming Fundamentals
0. Introduction
to Visual C++
Visual C++ Development Environment
Visual Studio
Managing Projects
Compiling and Linking
Debugging
Building a Program with a C++ Class
1. Introduction
to Windows Programming and MFC
Structure of Windows Programs
Application Frameworks
Class Hierarchy of the MFC Library
CWinApp and CFrameWnd Classes
Event-Driven Programming
Windows Messages
Message Maps
2. User
Input in Windows
Mouse
Using ClassWizard
Using Spy++
Invalidating the Client Area
Keyboard
3. Graphics
Device Interface
Device Contexts
GDI Object Creation and Cleanup
Colors
Pens and Brushes
Drawing with Text
4. More
About Windows
MFC Encapsulation of Windows
Window Creation and Destruction
Focus and Activation
Sending and Posting Messages
Overlapped, Popup and Child Windows
Child Windows and Owned Windows
5. Document/View
Architecture
Using AppWizard
Document and View Classes
Document Templates
SDI and MDI Applications
Document/View Program Structure
Synchronizing Document and Views
Making a Document Persistent
6. Menus
and Resources
Resources in Windows Programs
Developer Studio Resource Editors
String Tables
Menus and Command Messages
Update Command UI Messages
Keyboard Accelerators
7. Controls
and Dialogs
Modal and Modeless Dialog Boxes
Resources and Controls
Controls as Child Windows
CDialog Class and Programming a Modal Dialog
Designing Dialogs with Dialog Editor
Using ClassWizard
Dialog Data Transfer
8. Toolbars
and Status Bars
Command Messages
MFC Control Bar Classes
Toolbars and Tooltips
Idle Time Processing
Status Bars
Module 2. Intermediate MFC Windows Programming
1. Mouse
Techniques
Mouse Messages
Mouse Handler Functions
Capturing the Mouse
Mouse Cursor
Rubberband Drawing
Drag and Drop
2. MFC
Services
General Purpose Classes
Serialization and Persistent Objects
Diagnostics
Exceptions
Runtime Type Information in MFC
3. MFC
Collection Classes
List, Dynamic Array and Map Classes
Making Collection Objects Persistent
MFC Template Collection Classes
4. More
About Dialog Boxes
Modeless Dialogs as Child Windows
Communicating Between a Dialog and its Parent
Programming a Modeless Dialog
Combo Boxes and List Boxes
Common Dialogs
Fonts
Common Font Dialog
5. More
About Document/View
Multiple Document Interface
MFC Classes that Implement MDI
Implementing MDI Applications with MFC
Multiple View Types
Special View Classes
Form View Based Applications
6. Windows
Common Controls
Win32 Common Controls
MFC Common Control Classes
Progress and Slider Controls
Tree View Control
7. MFC
Database Classes
ODBC Architecture
MFC Classes for ODBC
Record Field Exchange
Scrolling in a Recordset
Choosing a Data Source at Runtime
Record Sets and Record Views
Data Access Objects
MFC Classes for DAO
8. Dynamic
Link Libraries
What is a Dynamic Link Library (DLL)
Creating a DLL
Debugging a DLL
9. Introduction
to ActiveX
COM, OLE and ActiveX
ActiveX Controls
Using ActiveX Controls in Programs
System Requirements
Software:
·
NT 4.0 or Windows 2000
·
Visual C++ 6
Hardware:
·
Pentium 500MHz or equivalent CPU
·
128 Meg of RAM
·
At least 500 megabytes of free disk space
·
CDROM drive or networked to a server with a CDROM drive