Microsoft KB Archive/181505

= PRB: ATL COM AppWizard Doesn't Offer MFC Support for .EXE =

Article ID: 181505

Article Last Modified on 11/18/2003

-

APPLIES TO

 The AppWizard, when used with:  Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition 

-



This article was previously published under Q181505



SYMPTOMS
The ATL COM AppWizard does not offer the option of MFC support for an .exe project. Adding an MFC class with ClassView or ClassWizard results in build errors.



RESOLUTION
To add minimal MFC support to an ATL COM AppWizard project, follow these steps:

 Open the ATL project with Visual C++.</li> On the Project menu, click Settings.</li> Under the General tab, set the Microsoft Foundation Classes field to "Use MFC in a Shared DLL" or "Use MFC in a Static Library". Click OK.</li>  Open the project StdAfx.h header file. Add the following line after "#define STRICT", then save and close the file: #include <afxdisp.h>                       </li> Open the project .rc source file in text mode for editing:

<ol style="list-style-type: lower-alpha;"> On the File menu, click Open.</li> Highlight the .rc file.</li> Set the Open As field to "Text", then click Open.</li> Click OK on any resulting message boxes.</li></ol> </li> Replace all occurrences of Winres.h with Afxres.h in the .rc file, then save and close the file.</li> Delete the .clw file if it already exists.</li> Invoke ClassWizard by clicking ClassWizard on the View menu. Click Yes when prompted to rebuild the ClassWizard database, and then click OK on the next dialog box.</li></ol>

MFC class files added with ClassView or ClassWizard should now build without errors.

<div class="status_section">

STATUS
This behavior is by design.

NOTE: In Visual C++ 6.0, another option exists. Create an MFC project first, and then click New ATL Object on the Insert menu. Click OK on the next dialog box to insert ATL support into the MFC project.

<div class="moreinformation_section">

Steps to Reproduce Behavior

 * 1) In Visual C++, create a new ATL COM AppWizard project.
 * 2) In the wizard's Step 1, select either "Executable (EXE)" or "Service (EXE)".

NOTE: The "Support MFC" check box is disabled.
 * 1) Finish the project. Click Finish, then click OK.
 * 2) On the ClassView pane of the new project, right-click the project name. Select New Class from the menu.
 * 3) Change Class Type to "MFC Class", give the class a name and a base class, then click OK.
 * 4) Build the project.

RESULT: Build errors prevent the build step from completing successfully.

<div class="references_section">