Chapter 16
Writing Applications with ATL
Although it is primarily a COM development tool, ATL is also a workable environment for creating Microsoft Win32 applications—but you have to get your hands a little dirty to get the job done. As of this writing, there is no AppWizard support for creating a Win32 EXE in ATL that doesn't have COM server code attached. The lack of a document/view framework, serialization support, and a printing abstraction means you'll have to roll your own if you need them. We'll dedicate this chapter to the creation of a simple ATL application named ATL Scribble, an SDI application that allows you to sketch on a window canvas with your mouse. ATL Scribble will have a menu and a toolbar, and will support persistence to a file. We'll use ATL for all the windowing in the project and the Standard Template Library (STL) for arrays and maps. We'll use the subject-observer design pattern to notify views when the scribble data changes. We'll keep the drawing and message-handling code separate from the windowing classes so that we can reuse it in both a view and a dialog box. The companion CD contains the complete source code for the project. This chapter isn't a tutorial, but we'll highlight the major areas involved in creating a Win32 project with ATL so that you can apply the same concepts to your own applications.