agent 中如何定义右键菜单触发事件?

whubhjt 2002-12-22 01:03:23
我用
Merlin.Commands.Add('Delphi2','Run Delphi','Delphi2',True,True);
在agent上添加了一个右键菜单选项 Run Delphi
但是同时多了一个“打开声音命令窗口”选项
1、如何去掉“打开声音命令窗口”选项。
2、如何控制"Run Delphi"选项(agent的添加出来的右键菜单项)点击后打开form2?
...全文
61 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
INeedCa 2002-12-23
  • 打赏
  • 举报
回复
不可能吧。
你跟一下是否进TForm1.myAgentCommand这个事件了。
atyzy 2002-12-22
  • 打赏
  • 举报
回复
whubhjt (带刀侍卫) :你是真高手,可惜你的问题我不会,我有一个简单的问题,能不能麻烦看一下.谢谢
http://expert.csdn.net/Expert/topic/1245/1245005.xml?temp=.2996942
whubhjt 2002-12-22
  • 打赏
  • 举报
回复
我翻了翻以前的问题
其中INeedCa同志说:

procedure TForm1.Button1Click(Sender: TObject);
begin
Genie.Commands.Add('1', 'Yes', '', True, True);
Genie.Commands.Add('2', 'No', '', True, True);
end;

procedure TForm1.Agent1Command(Sender: TObject;
const UserInput: IDispatch);
begin
if IAgentCtlUserInput(UserInput).Name = '1' then begin
ShowMessage('Yes');
end
else if IAgentCtlUserInput(UserInput).Name = '2' then begin
ShowMessage('No');
end
end;

我照做了,但是右键菜单有,但是还是不能响应动作ShowMessage,请大家再帮我看看哪,
全部源代码如下:
unit Unit1;

interface

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

type
TForm1 = class(TForm)
myAgent: TAgent;
Button1: TButton;
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure myAgentCommand(Sender: TObject;
const UserInput: IDispatch);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Peedy: IagentCtlCharacter; Request1,Request2: IagentCtlRequest;
implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
begin
Request1 := MyAgent.Characters.Load( 'Peedy', extractfilepath(application.exename)+'\rover.acs' );
Peedy := MyAgent.Characters.Character('Peedy');
peedy.Show(0)
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
peedy.Commands.Add('1','Yes','',True,True);
peedy.Commands.Add('2','No','',True,True);
end;
procedure TForm1.myAgentCommand(Sender: TObject;
const UserInput: IDispatch);
begin
if IAgentCtlUserInput(UserInput).Name = '1' then begin
ShowMessage('Yes');
end
else if IAgentCtlUserInput(UserInput).Name = '2' then begin
ShowMessage('No');
end
end;
end.

5,931

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧