ATLAgent Attributes Sample: Uses CCommand and CAccessor to Read Information from a Database
The ATLAgent attributes sample reads instructions from a database using the OLE DB Consumer Template classes. These instructions are used to command the Microsoft Agent control. The sample demonstrates how to use the CCommand and CAccessor classes to read information from a database and how to use the compiler COM support to control the Microsoft Agent.
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.
To get samples and instructions for installing them:
On the Visual Studio Help menu, click Samples.
For more information, see Visual Studio Samples.
The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.
You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.
To install the Microsoft Agent control
Download the Microsoft Agent control from http://go.microsoft.com/fwlink/?linkid=558.
Optionally, download the text-to-speech engine available from the same page to allow the agent to speak.
Choose the link to download the Microsoft Agent character animation files and download one or more of the character .acs files. By default the ATLAgent control uses the Merlin-with-sound-effects character (merlinsfx.acs). Save the files to the directory where you have installed Microsoft Agent, typically C:\Program Files\Microsoft Agent\.
To use the Microsoft Agent control
Set up a Microsoft Access data source called Agent and point the data source to the Agent.mdb file contained in the sample's directory as follows:
In Control Panel, select Administrative Tools, then select Data Sources (ODBC); the ODBC Data Source Administrator dialog box appears.
In the ODBC Data Source Administrator dialog box, go to the System DSN tab, then click Add; the Create New Data Source dialog box appears.
In the Create New Data Source dialog box, from the list of data sources, choose "Microsoft Access Driver (*.mdb)" then click Finish; the ODBC Microsoft Access Setup dialog box appears.
In the ODBC Microsoft Access Setup dialog box, in Data Source Name, type "Agent" then click Advanced; the Set Advanced Options dialog box appears.
In Set Advanced Options dialog box, under Options, select DefaultDir, and enter the path to the Agent.mdb file as the DefaultDir property.
Modify the directory locations at the beginning of AgentCtl.h if you have installed Microsoft Agent in a different directory.
Copy the ATLAgent project files and build the ATLAgent project.
Open ATLAgent.htm from the sample and click the Play button. The Agent should appear and should follow the instructions contained in the Instructions table in the Agent.mdb database.
This sample uses the following attributes:
coclass, db_column, db_source, db_table, default, dll, dual, helpstring, id, in, module, name, object, out, pointer_default, progid, propget, propput, retval, uuid, vi_progid
Some of the samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.