size : 1984
uploaded_on : Tue Feb 1 10:47:37 2000
modified_on : Tue Feb 1 11:30:09 2000
title : Programming Agents like Office Assistant
org_filename : C:\CKB\msagent.txt
author : Nirmal
authoremail : nirmalkannan@hotmail.com
description : Describes how to Program Ms Agent in Delphi
keywords : ActiveX , Office Assistant
tested : Delphi 5.0
submitted_by : The CKB Crew
submitted_by_email : ckb@netalive.org
uploaded_by : kannan
modified_by : kannan
owner : kannan
lang : Delphi
file-type : text/plain
category : delphi_ole
__END_OF_HEADER__
Basically MS Agent is an Active X mechanism which allows the Programmers to
create an instance of an ActiveX control namely Agent , The Agent is able to
maintain a Collection of Character Objects (Assistants such as Cllipit , Genius).
Each Character is actually an instance of IAgentCtlCharacter interface. Which has
a number of functions including the function to Show the Assistant .So What we need
is just create an instance of Agent Control , Load some characters , Use the Character
interface to show the agent .
Microsoft has introduced a new format to store the Agent Character's) , namely *.ACS .
There are also file formats which are used when Agent is used for Web.for Creating these
Character Sets , Microsoft distributes a Character editor , free to download from www.microsoft.com/msagent.
There are a few ACS files like Genie.ACS which Microsoft allows to distribute for free with your apps.
If you have MS Office installed on your system , you can easily find sample ACS files .
Delphi which provides Compiler support for COM can wrap the interface of particular COM object to
an easy to use VCL component .So first import the type library ,For that Select Project->ImportTypeLibrary
and then import type library of Microsoft Agent Control 2.0 (If MS Office is installed in your system ,
if not you've to download Agent control from from Microsoft web site before that), On doing so a
TAgent Component will appear in ActiveX tab just drag the component in form and you can program Office Assistant.
Following Code snippet simply shows agent when user clicks button.
procedure TForm1.Button1Click(Sender: TObject);
var
a,b:IAgentCtlCharacter;
begin
Agent1.Characters.Load('Genius','Genius.acs');
a:=Agent1.Characters.Get_Item('Genius');
a.Show(0);
Agent1.Characters.Load('Clippit','Clippit.acs');
b:=Agent1.Characters.Get_Item('Clippit');
b.Show(0);
end;
PS:Don't forget to change copy ACS files to the directory specified !