Home | Overview | How Do I | Tutorial
ClassWizard supports the following Automation features:
You must call AfxOleInit in InitInstance to initialize Automation for your application.
For more information, see the article ClassWizard: Accessing Automation Servers.
An Automation class has a programming interface that other applications use to manipulate objects that your application implements. This is referred to as a "dispatch interface." For more information about dispatch interfaces, see Dispatch Interface and API Functions in the Win32 SDK.
ClassWizard's Add Class button now allows you to create classes supporting Automation. Click this button on the Automation tab to display a dialog box in which you can choose to create a new class or import an existing class. The New Class dialog box appears if you create a new class so you can specify the name of your class, the base class, the filenames in which your class is implemented, and the dialog display resource for the base class, if necessary. You can also choose whether your class supports Automation, and whether to add the new class to the Gallery.
To add an Automation class
Type new names for the .h and .cpp files. Alternately, you can use the Browse buttons to select files. Then click OK to return to the New Class dialog box.
To continue defining the dispatch interface for your Automation class, see the article ClassWizard: Adding Automation Properties and Methods.
A class that is OLE Creatable allows other applications to create a stand-alone object of the class, for example by using the Visual Basic function CreateObject, and to incorporate that automation object into their application. In general, you should make only your top-level classes, such as documents, creatable from other OLE applications. Classes that are parts of these top-level classes are usually not OLE Creatable and are instead accessed from a member function in the top-level class.
For example, consider a list document, which contains a list of items. It's a good idea to make the top-level document class OLE Creatable, because this allows other applications to create a list from nothing. You then add/enumerate the items in the list, but you cannot create them as stand-alone objects because they depend on their position inside the list. For this reason, only stand-alone objects should be OLE Creatable. Note that if you selected Creatable By Type ID in AppWizard your document class is OLE Creatable. In other words, it can be accessed by automation clients.
Note OLE insertable items are made possible by class COleTemplateServer. When you choose OLE support in AppWizard, a COleTemplateServer object manages your documents. Such documents can be created by Automation.
The following articles explain the details of using ClassWizard's OLE support: