- Table of Contents
- Copyright
- About the Authors
- About the Contributors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- How to Use This Book
- What You Need to Use This Book
- What's New in Visual C++ 6.0
- Contacting the Main Author
- Part I: Introduction
- Chapter 1. The Visual C++ 6.0 Environment
- Part II: MFC Programming
- Chapter 2. MFC Class Library Overview
- Chapter 3. MFC Message Handling Mechanism
- Chapter 4. The Document View Architecture
- Chapter 5. Creating and Using Dialog Boxes
- Chapter 6. Working with Device Contexts and GDI Objects
- Chapter 7. Creating and Using Property Sheets
- Chapter 8. Working with the File System
- Chapter 9. Using Serialization with File and Archive Objects
- Part III: Internet Programming with MFC
- Chapter 10. MFC and the Internet Server API (ISAPI)
- Chapter 11. The WinInet API
- Chapter 12. MFC HTML Support
- Part IV: Advanced Programming Topics
- Chapter 13. Using the Standard C++ Library
- Standard C++ Library
- Standard Template Library (STL)
- Containers
- Iterators
- Algorithms
- Using STL with MFC and ATL
- Summary
- Chapter 14. Error Detection and Exception Handling Techniques
- Chapter 15. Debugging and Profiling Strategies
- Chapter 16. Multithreading
- Chapter 17. Using Scripting and Other Tools to Automate the Visual C++ IDE
- Part V: Database Programming
- Chapter 18. Creating Custom AppWizards
- Chapter 19. Database Overview
- Chapter 20. ODBC Programming
- Chapter 21. MFC Database Classes
- Chapter 22. Using OLE DB
- Chapter 23. Programming with ADO
- Part VI: MFC Support for COM and ActiveX
- Chapter 24. Overview of COM and Active Technologies
- Chapter 25. Active Documents
- Chapter 26. Active Containers
- Chapter 27. Active Servers
- Chapter 28. ActiveX Controls
- Part VII: Using the Active Template Library
- Chapter 29. ATL Architecture
- Chapter 30. Creating COM Objects Using ATL
- Chapter 31. Creating ActiveX Controls Using ATL
- Chapter 32. Using ATL to Create MTS and COM+ Components
- Part VIII: Finishing Touches
- Chapter 33. Adding Windows Help
- Part IX: Appendix
Using STL with MFC and ATL
This section will briefly introduce how to use STL with MFC and introduce the Active Template Library (ATL).
Using STL with MFC
The MFC Library is a set of more than 100 classes. All of the classes are tested and optimized, and the MFC Library contains data structure classes similar to STL—such as arrays, lists, and string lists. MFC is quite sufficient when compared to STL, and when it comes down to it, you probably won't come to a point where you have to have STL. When you are using MFC, however, the advantage of a lightweight program is lost, because you must bring along the DLL with distribution. So, what advantage is there in using STL with MFC?
Using STL with MFC enables easier traversal through MFC window containers. Thus, you want to use STL with MFC to help simplify MFC use and expand its use with the STL algorithms.
Introduction to ATL
ATL stands for Active Template Library. This library is designed to provide a way to create COM components in a fast and easy manner, and they leave only a small memory footprint. With ATL, you can create COM objects, Automation Server controls, and Active X controls, as well as provide built-in support for fundamental COM interfaces. ATL is an excellent partner to STL in that ATL has no provisions for data structures and algorithms, and STL fits that bill nicely.
Remember that template libraries are distributed as source code, which is a major advantage compared to function libraries. Because ATL is a template library, it only has to include the source needed in the executable, unlike MFC.
ATL Versus MFC
Which one should you use with STL? In short, use ATL to create a COM component when all of the built-in functionality of MFC is not necessary. When the component that is being created is nonvisual, ATL is most likely the better choice. ATL implementation results in faster components that use much less memory and do not carry the excess luggage of DLLs.
Summary | Next Section

Account Sign In
View your cart