200分大奉送,哪位大虾知道OFFICE的助手角色的编程(200分)

  • 主题发起人 主题发起人 wjing
  • 开始时间 开始时间
W

wjing

Unregistered / Unconfirmed
GUEST, unregistred user!
使用过OFFICE吧(别说没有),一定注意到那个助手'铁丝'吧,不知哪位知道如何对其编程.
 
微软提供了 ActiveX 控件 MSAgent ,你可以用它来实现自己的“助手”。
 
对,用专门的控件就行了啊
 
可以自己做一个呀!
 
能具体到哪个控件吗?
 
是标准的ocx.
 
Import ActiveX Control-->M$ Agent Control.
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleCtrls, AgentObjects_TLB;

type
TForm1 = class(TForm)
Agent1: TAgent;
GroupBox1: TGroupBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
GroupBox2: TGroupBox;
ListBox1: TListBox;
GroupBox3: TGroupBox;
Edit1: TEdit;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.DFM}
//Button1.Caption:='Connect'

procedure TForm1.Button1Click(Sender: TObject);
var
dd:olevariant;
begin

with agent1.Charactersdo

begin

Load('mime','d:/office/office/saeko.acs');
Item['mime'].Show(dd);
item['mime'].LanguageID:=$409;
Item['mime'].Speak('Hello',dd);
end;

button2.enabled:=true;button3.Enabled:=true;button4.Enabled:=true;
button1.Enabled:=false;
end;

//Button2.Caption:='Get Animates Names'
procedure TForm1.Button2Click(Sender: TObject);
var
i,count:integer;
str:IagentCtlAnimationNames;
outer:string;
begin

listbox1.items.clear;
listbox1.items.add('Name:'+agent1.Characters.Item['mime'].Get_Name);
listbox1.Items.Add('Version:'+agent1.Characters.Item['mime'].Get_Version);
listbox1.Items.Add('Description:'+agent1.Characters.Item['mime'].Get_Description);
listbox1.Items.Add('Command Caption'+agent1.Characters.Item['mime'].Commands.Caption);
agent1.Characters.Item['mime'].AnimationNames.GetTypeInfoCount(count);
for i:=0 to countdo

begin

str:=agent1.Characters.Item['mime'].Get_AnimationNames;
str.GetTypeInfo(i,agent1.Characters.Item['mime'].Get_LanguageID,outer);
listbox1.Items.Add(outer);
end;

end;

//Button3.Captioin:='DisConnect'
procedure TForm1.Button3Click(Sender: TObject);
begin

agent1.Characters.Unload('mime');
button1.Enabled:=true;button2.Enabled:=false;button4.Enabled:=false;
end;

//Button4.Caption:='Speak'
procedure TForm1.Button4Click(Sender: TObject);
var
url:olevariant;
begin

agent1.Characters.Item['mime'].Speak(edit1.text,url);
end;


procedure TForm1.FormCreate(Sender: TObject);
var
width,i:integer;
begin

width:=0;
for i:=0 to listbox1.Items.Count-1do

begin

if width<listbox1.Canvas.TextWidth(listbox1.items.strings) then

width:=listbox1.Canvas.TextWidth(listbox1.items.strings);
end;

sendmessage(listbox1.handle,LB_SETHORIZONTALEXTENT,width+2,0);
end;


end.
 
谢谢各位
 
后退
顶部