Developers Workshop to COM and ATL 3.0

 < Free Open Study > 


The Active Template Library is the preferred C++ framework for building COM components. Using integrated CASE tools, numerous maps, classes, and templates, a developer is able to live a relatively sane COM existence. Given that COM is the architecture behind all ActiveX-based technologies, it is no surprise that ATL shines as a framework for building ActiveX controls. These COM objects are unique in that they tend to move beyond the non-GUI business objects we have been examining thus far and provide an interactive user interface. Many ActiveX controls also provide a set of "property pages" that allow the consumers of these controls to configure the state of the object during design time. Because each of these COM technologies requires a user interface, it stands to reason that ATL provides some help constructing GUIs.

As a Win32 programmer, you have probably needed to develop a user interface at some time in your career. If you are a C++ snob, you may scoff at the idea of using Visual Basic as a tool for building your GUIs, and may opt to use the Microsoft Foundation Classes (MFC). Beyond providing a number of CASE tools (MFC AppWizard, ClassWizard, and so on) to help get the guts of a Windows application up and running, MFC provides a healthy dose of classes, which encapsulates you from the boilerplate details behind each and every window (e.g., WinMain(), the WndProc, and WNDCLASSEX, just to name a few such details).

Given that we already have the MFC framework to build full Win32 applications, why would ATL also provide help in this area? Again, the answer lies in the fact that not all COM objects are invisible logic crunchers. ATL's support for ActiveX controls and their associated property pages is provided in part by a set of window-based templates, as well as another ATL map to help process Windows messages. However, beyond using these windowing templates to create GUI-based COM objects, you are also able to build full-scale Win32 stand-alone EXEs using ATL.

As you will see, ATL provides a "just thick enough" wrapper around the Windows API. When you use ATL as a framework for building Win32 applications, you are not given as much support as you would find in MFC. For example, ATL does not provide support for the MFC ClassWizard utility, offers no support for Dialog Data Exchange and Validation (DDX/DDV) routines, and does not provide a document/view/frame/application paradigm. In general, when you are using ATL to build traditional Windows applications, you are back to working with raw Win32 primitives to get the job done (this is your cue to pull out that copy of Petzold's Programming Windows you thought you were finished with).

So then, in this chapter we will come to understand the set of ATL templates, structures, and CASE tools used to build main windows and dialog boxes. Once you have worked through this material you will be in a perfect position to build ActiveX controls using ATL (the subject of the next chapter), given that a full-featured control makes use of many of the following ATL windowing techniques.


 < Free Open Study > 

Категории