Home | Overview | How Do I | Tutorial
To add classes derived from MFC (Microsoft Foundation Class Library) classes to your project, you can use any of the following tools: ClassView, WizardBar, ClassWizard, or the New Class command on the Insert menu. You simply specify the new class's name, select the base class from which it is to be derived, and select the ID of the dialog box with which it is to be associated (if any). WizardBar creates a header file and an implementation file for the new class.
Note You can add MFC classes to an ATL COM application if you initially created the application with MFC support.
To add an MFC class to your project
The name you specify is reflected in the read-only File name box, where the .cpp file is specified. By default, the header file and the implementation file have the same name as the class file.
Classes such as CButton or CEdit that are derived from base classes other than CDaoRecordView, CDialog, CFormView, CPropertyPage, or CRecordView do not require a resource ID. Because these classes do not require a resource ID, the New Class dialog's Dialog ID drop-down list is not active.
For classes that require a resource ID (classes derived from CDaoRecordView, CDialog, CFormView, CPropertyPage, or CRecordView), it is more efficient if you first use the dialog editor to create the resource and its ID, then use ClassWizard to create a class associated with that resource ID.
However, if you create the class first, then the resource, you can later associate the class to the resource using the procedure described in Associate an Existing Class with a Resource.
For information on using the resource editors, see Resource Editor Topics (Specific to Visual C++).
For information about creating database classes (CRecordView, CRecordset) and OLE classes, see the article ClassWizard: Database Support.
If you select this option, the newly created class will be available as a programmable object by automation client applications, such as Microsoft Visual Basic™ and Microsoft Excel. This option is available only for some classes.
With this option, automation clients can directly create an Automation object. The type ID in the text box is used by the client application to specify the object to be created; it is system-wide and must be unique. This option is available only for some classes.
Note Use ClassWizard's Automation tab to add Automation methods and properties to an existing class. These methods and properties define a dispatch interface that Automation clients can use.
The new class immediately appears in ClassView, and you can view its header and implementation files in the FileView pane of the project workspace.
See Also Adding an ATL Class, Adding a Generic Class