The following section illustrates how you can create an ATL client EXE
project that automates Microsoft Excel. You can use the first 10 steps for
any project, and modify step 11 when you work with another application.
With Microsoft Developer Studio 6.0, start a new "ATL COM AppWizard"
project named "AtlClientApp."
In step 1 of the ATL AppWizard, choose "Executable (EXE)" for the Server
Type and then click Finish. The New Project Information dialog box
appears and shows the classes to be created. Click OK to create the
project.
From the Insert menu, select "New ATL Object" to bring up the ATL
Object Wizard. For the type of Object to insert, select Miscellaneous
and pick Dialog to a add a Dialog Object to the project. Click Next
to continue.
Provide a short name of "ClientDlg" for your new dialog. Accept the
defaults for all other names and click OK.
In the project workspace, click the "Resource View" tab. Double-click
"AtlClientApp Resources" to expand the resource tree. Double-click
Dialog in the Resource tree and double-click to select the dialog
box resource "IDD_CLIENTDLG."
Change the caption of the OK button to "Run" and the cancel button to
"Quit." Leave the button IDs at their default settings and close the
dialog box design form.
In the project workspace, click the "Class View" tab. Double-click the "Globals" folder to see the "_tWinMain" entry point, then double-click "_tWinMain" to jump to the code location.
Replace all the code in the function with the following:
At the top of the file, add the following include statement after the
others:
#include "ClientDlg.h"
From the "Class View" tab, expand the "CClientDlg" class to reveal its
class members. Find the "OnCancel" method and double-click it to jump
to the code. Replace the code in the function with the following:
Because you are building a client application, you do not need to
perform COM registration when you compile the EXE. To remove this step,
select "Settings" from the Project menu, go to the "Custom Build" tab,
and remove the all the commands that appear in the "Build Commands"
window. Do the same for the "Outputs" window, and click OK when done.
Compile your project by selecting "Rebuild All" from the Build menu.
Run your project by pressing the F5 key.