As you've seen so far, ATL is a great framework for developing plain-vanilla COM classes. By using ATL, you can spend less time worrying about QueryInterface and more time reading Dilbert. In addition to being a great framework for developing simple COM classes, ATL is a wonderful framework for developing Microsoft ActiveX controls. This chapter covers the basics of using ATL to develop ActiveX controls.
Even now, some confusion remains about what really constitutes an ActiveX control. In 1994, Microsoft developed some new interfaces in addition to its object linking and embedding (OLE) protocol, packaged these interfaces within DLLs, and called them OLE controls. Originally, OLE controls implemented nearly the entire OLE Embedding protocol. In addition, OLE controls supported the following features:
When the Internet became a predominant factor in Microsoft's business plans, Microsoft announced its intention to plant COM-based controls on Web pages. It was at this point that the size of these components became an issue. Microsoft took its OLE control specification, changed the name from OLE controls to ActiveX controls, and stated that all the features listed above were optional. This meant that under the new ActiveX control definition, a control's only requirement was that it be based on COM (read: the object implements IUnknown). Of course, for a control to be useful, it really needs to implement several of the features listed above. So in some cases, ActiveX controls and OLE controls refer to more or less the same animal. In other cases, ActiveX controls can be a little bit lighter and not implement so many of the features. This chapter covers the kinds of ActiveX controls you can create using ATL.