关于Ms Agent 的使用,急!!(100分)

  • 主题发起人 主题发起人 dcba
  • 开始时间 开始时间
D

dcba

Unregistered / Unconfirmed
GUEST, unregistred user!
1、那里有Microsoft Agent Character Editor 下载?
2、怎样用Agent自己的方法实现气泡窗口(像Office的)而且上面还有按钮?
 
http://www.microsoft.com/products/msagent/devdownloads.htm
 
那么怎样用Agent自己的方法实现气泡窗口(像Office的)而且上面还有按钮?
 
到微软的站点看看好像有关于Agent的介绍应该有你需要的。
 
飘摇客:能不能给出具体的链接地址?或是代码呢?
 
http://www.vclxx.org/DELPHI/D32SAMPL/AGENTS.ZIP
AGENTS.ZIP
示範如何利用 Delphi 來操控 Microsoft Agent 2.0 版中各式卡通人物,作者 : Richard Minutillo。
 
tayancom:
我下载了你的代码示例,但是编译错误,有很多地方语法错误,你可以编译么?
 
1.windows 要有install Microsoft Agent version 2.0 Control以上
2.project -> imported type library -> Agent control 到 Delphi內
它會自動產生 TAgent 控件
3.開啟 PureAgent2.dpr
 
tayancom:
你好,你说的那些步骤我都做过了,我从delphi中安装agent时,版本是2.0的,但是问题在于生成的单元文件感觉有问题:
1、单元声明的文件中,TAgent.Characters是IAgentCtlCharacters,而程序中使用时把它当作IAgentCtlCharactersEx使用,故产生错误:“[Error] PureAgent2Unit.pas(325): Incompatible types: 'IAgentCtlCharacter' and 'IAgentCtlCharacterEx'”
2、同样类似的错误还有把IAgentCtlCharacterEx.Balloon属性当作IAgentCtlBalloonEx,而单元文件中声明的是IAgentCtlBalloon。因而产生:“[Error] CharForm.pas(146): Undeclared identifier: 'Style'”错误

delphi自动生成的单元文件如下:
unit AgentObjects_TLB;

// ************************************************************************ //
// Type Lib: C:/WINDOWS/msagent/AgentCtl.dll (1)
// LIBID: {F5BE8BC2-7DE6-11D0-91FE-00C04FD701A5}
// LCID: 0
// Helpfile:
// DepndLst:
// (1) v2.0 stdole, (C:/WINDOWS/System32/stdole2.tlb)
// (2) v4.0 StdVCL, (C:/WINDOWS/System32/STDVCL40.DLL)
// Errors:
// Hint: Parameter 'On' of IAgentCtlCharacter.IdleOn changed to 'On_'
// Hint: Parameter 'On' of IAgentCtlCharacter.IdleOn changed to 'On_'
// Hint: Parameter 'Type' of IAgentCtlCharacter.Get changed to 'Type_'
// Hint: Parameter 'On' of IAgentCtlCharacter.SoundEffectsOn changed to 'On_'
// Hint: Parameter 'On' of IAgentCtlCharacter.SoundEffectsOn changed to 'On_'
// Hint: Parameter 'On' of IAgentCtlCharacterEx.AutoPopupMenu changed to 'On_'
// Hint: Parameter 'On' of IAgentCtlCharacterEx.AutoPopupMenu changed to 'On_'
// Hint: Parameter 'On' of IAgentCtlCharacterEx.HelpModeOn changed to 'On_'
// Hint: Parameter 'On' of IAgentCtlCharacterEx.HelpModeOn changed to 'On_'
// Hint: Parameter 'File' of IAgentCtlCharacterEx.HelpFile changed to 'File_'
// Hint: Parameter 'File' of IAgentCtlCharacterEx.HelpFile changed to 'File_'
// ************************************************************************ //
// *************************************************************************//

{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}

interface

uses Windows, ActiveX, Classes, Graphics, OleCtrls, OleServer, StdVCL, Variants;

TAgent = class(TOleControl)
private
......
protected
......
public
procedure ShowDefaultCharacterProperties
overload;
procedure ShowDefaultCharacterProperties(x: OleVariant)
overload;
procedure ShowDefaultCharacterProperties(x: OleVariant
y: OleVariant)
overload;
property ControlInterface: IAgentCtlEx read GetControlInterface;
property DefaultInterface: IAgentCtlEx read GetControlInterface;
property [blue]Characters:[/blue] [red]IAgentCtlCharacters[/red] read Get_Characters;
property AudioOutput: IAgentCtlAudioObjectEx read Get_AudioOutput;
property SpeechInput: IAgentCtlSpeechInput read Get_SpeechInput;
property PropertySheet: IAgentCtlPropertySheet read Get_PropertySheet;
property CommandsWindow: IAgentCtlCommandsWindow read Get_CommandsWindow;
property Suspended: WordBool index 14 read GetWordBoolProp;
published
property Connected: WordBool index 9 read GetWordBoolProp write SetWordBoolProp stored False;
property RaiseRequestErrors: WordBool index 21 read GetWordBoolProp write SetWordBoolProp stored False;
property OnActivateInput: TAgentActivateInput read FOnActivateInput write FOnActivateInput;
property OnDeactivateInput: TAgentDeactivateInput read FOnDeactivateInput write FOnDeactivateInput;
property OnClick: TAgentClick read FOnClick write FOnClick;
property OnDblClick: TAgentDblClick read FOnDblClick write FOnDblClick;
property OnDragStart: TAgentDragStart read FOnDragStart write FOnDragStart;
property OnDragComplete: TAgentDragComplete read FOnDragComplete write FOnDragComplete;
property OnShow: TAgentShow read FOnShow write FOnShow;
property OnHide: TAgentHide read FOnHide write FOnHide;
property OnRequestStart: TAgentRequestStart read FOnRequestStart write FOnRequestStart;
property OnRequestComplete: TAgentRequestComplete read FOnRequestComplete write FOnRequestComplete;
property OnRestart: TNotifyEvent read FOnRestart write FOnRestart;
property OnShutdown: TNotifyEvent read FOnShutdown write FOnShutdown;
property OnBookmark: TAgentBookmark read FOnBookmark write FOnBookmark;
property OnCommand: TAgentCommand read FOnCommand write FOnCommand;
property OnIdleStart: TAgentIdleStart read FOnIdleStart write FOnIdleStart;
property OnIdleComplete: TAgentIdleComplete read FOnIdleComplete write FOnIdleComplete;
property OnMove: TAgentMove read FOnMove write FOnMove;
property OnSize: TAgentSize read FOnSize write FOnSize;
property OnBalloonShow: TAgentBalloonShow read FOnBalloonShow write FOnBalloonShow;
property OnBalloonHide: TAgentBalloonHide read FOnBalloonHide write FOnBalloonHide;
property OnHelpComplete: TAgentHelpComplete read FOnHelpComplete write FOnHelpComplete;
property OnListenStart: TAgentListenStart read FOnListenStart write FOnListenStart;
property OnListenComplete: TAgentListenComplete read FOnListenComplete write FOnListenComplete;
property OnDefaultCharacterChange: TAgentDefaultCharacterChange read FOnDefaultCharacterChange write FOnDefaultCharacterChange;
property OnAgentPropertyChange: TNotifyEvent read FOnAgentPropertyChange write FOnAgentPropertyChange;
property OnActiveClientChange: TAgentActiveClientChange read FOnActiveClientChange write FOnActiveClientChange;
end;

procedure Register;

resourcestring
dtlServerPage = 'ActiveX';

implementation

uses ComObj;

......

end.
这是为什么?
 
代码示例: Form放入TAgent控件


unit Unit1;

interface

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

type
TForm1 = class(TForm)
Agent: TAgent;
Button1: TButton;
Button2: TButton;
Button5: TButton;
Button4: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
AgentLoaded: Boolean;
ThisCharEX: IAgentCtlCharacterEx;
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var Loadkey: olevariant;
begin
if AgentLoaded = False then begin
try
Agent.Connected := True;
Agent.Characters.Load('DefChar', LoadKey);
AgentLoaded := True;
ThisCharEx := Agent.Characters['DefChar'];
ThisCharEx.Top := 300;
ThisCharEx.Left := 200;
ThisCharEx.Show(False);
except
AgentLoaded := False;
showmessage('Load Error !');
end;
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if AgentLoaded then ThisCharEX.Speak('Hello !', '');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
if AgentLoaded then ThisCharEX.Think('How are You ?');
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
//play Events:
//Congratulate_2
//GetAttention
//Greet
//Pleased
//...........
if AgentLoaded then ThisCharEx.Play('Congratulate_2');
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
if AgentLoaded then begin
if ThisCharEx.Commands.Count > 0 then ThisCharEx.Commands.RemoveAll;
try
Agent.Characters.Unload('DefChar');
Agent.Connected := False;
AgentLoaded := False;
except
Agent.Characters.Unload('DefChar');
AgentLoaded := False;
end;
end
else showmessage('No Load !');
end;

end.
 
tayancom:
你好,谢谢你的程序,但是
有一个错误:[Error] Unit1.pas(45): Incompatible types: 'IAgentCtlCharacter' and 'IAgentCtlCharacterEx'
是由[red]procedure TForm1.Button1Click(Sender: TObject)[/red]
里的[red]ThisCharEx := Agent.Characters['DefChar'];[/red]句引起的。(Line 45)
原因是你声明的[green]ThisCharEx为IAgentCtlCharacterEx[/green]类型,而在[red]unit AgentObjects_TLB[/red]中
TAgent = class(TOleControl)
private
.....
protected
.....
public
.....
[purple]property Characters: IAgentCtlCharacters read Get_Characters;[/purple]
.....
end;

而IAgentCtlCharacters = interface(IDispatch)
['{F5BE8BE8-7DE6-11D0-91FE-00C04FD701A5}']
function Get_Item(const CharacterID: WideString): IAgentCtlCharacter
safecall;
[red]function Character(const CharacterID: WideString): IAgentCtlCharacter
safecall;[/red]
function Get_Enum: IUnknown
safecall;
procedure Unload(const CharacterID: WideString)
safecall;
function Load(const CharacterID: WideString
LoadKey: OleVariant): IAgentCtlRequest
safecall;
property Item[const CharacterID: WideString]: IAgentCtlCharacter read Get_Item
default;
property Enum: IUnknown read Get_Enum;
end;
是IAgentCtlCharacter的类型。
如果把ThisCharEx[green]改为[/green]ThisCharEx:IAgentCtlCharacter;则
procedure TForm1.Button3Click(Sender: TObject);
begin
if AgentLoaded then ThisCharEX.Think('How are You ?');
end;
又会出错,应为IAgentCtlCharacter没有Think方法,你的AgentObjects_TLB单元文件和我的不一样么?
 
您好像是用Delphi4 ?
1.我的環境:win98 se, Delphi5 up1, 可以正常RUN
2.您檢查步驟對不對
project -> imported type library -> Microsoft Agent control 2.0(Version 2.0)
-> install 它會在Palette的ActiveX內自動產生 TAgent 控件.
3.假如再不行,我也不知道了

 
tayancom:
我用的是Delphi6.0+up1+win xp,按照你说的步骤还是一样,就是[red]AgentObjects_TLB[/red]单元里的一些声明的问题,
为什么我的就是IAgentCtlCharacter 而不是'IAgentCtlCharacter[red][blue]Ex[/blue][/red]
TAgent = class(TOleControl)
private
.....
protected
.....
public
.....
property [gold]Characters: IAgentCtlCharacters read Get_Characters;[/gold]
.....
end;
 
留Mail,我寄我的AgentObjects_TLB.pas 給您試試
 
tayancom
多谢 likelyboy@etang.com
期待
 
tayancom:
谢谢你,是的,我的AgentObjects_TLB.pas和你的确实不一样,十分感谢你
我还有个问题就是为什么delphi自动生成的文件不一样呢?你的agent是在那里下在安装的?
可以告诉我么?还有就是你知道怎样用Agent自己的方法实现有[red]各种按钮[/red]气泡窗口?
 
>我还有个问题就是为什么delphi自动生成的文件不一样呢?你的agent是在那里下在安装的?
microsoft
>可以告诉我么?还有就是你知道怎样用Agent自己的方法实现有[red]各种按钮[/red]气泡窗口?
看我寫給您的代码示例,可顯示對話及指定動作,無法实现各种按钮
我發覺您好像都不到microsoft的網站看文件,那兒有說明及使用方法.
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
911
DelphiTeacher的专栏
D
D
回复
0
查看
868
DelphiTeacher的专栏
D
S
回复
0
查看
738
SUNSTONE的Delphi笔记
S
后退
顶部