Article ID: 191950
Article Last Modified on 6/29/2004
Common\Tools\Vb\Msagent
*-- Code begins here.
PUBLIC oGenie, oAgent
*-- Initialize the Agent object, which then allows us to
*-- load and use characters.
oAgent = createobject("Agent.Control.1")
oAgent.connected = .t.
*-- Load a character from the character definition.
*-- Modify the path to point to where the character
*-- definition is installed.
oAgent.characters.load("Genie", ;
"\program files\microsoft agent\characters\genie.acs")
*-- Create the character object, the Genie in this example.
oGenie = oAgent.characters("Genie")
oGenie.Show
Control = CREATEOBJECT("Form1")
Control.Show
READ EVENTS
**************************************************
*-- Form: form1
*-- ParentClass: form
*-- BaseClass: form
*
DEFINE CLASS form1 AS form
Top = 31
Left = 80
Height = 279
Width = 368
DoCreate = .T.
Caption = "Agent Control"
Name = "Form1"
ADD OBJECT text1 AS textbox WITH ;
Height = 25, ;
Left = 11, ;
Top = 30, ;
Width = 337, ;
Name = "Text1"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 72, ;
Left = 12, ;
Height = 37, ;
Width = 96, ;
Caption = "Speak", ;
Name = "Command1"
ADD OBJECT label1 AS label WITH ;
Caption = "Enter text below:", ;
Height = 25, ;
Left = 11, ;
Top = 6, ;
Width = 120, ;
Name = "Label1"
ADD OBJECT cmdmove AS commandbutton WITH ;
Top = 228, ;
Left = 36, ;
Height = 37, ;
Width = 84, ;
Caption = "Move", ;
Name = "cmdMove"
ADD OBJECT spntop AS spinner WITH ;
Height = 24, ;
Left = 97, ;
Top = 132, ;
Width = 60, ;
Value = 50, ;
Name = "spnTop"
ADD OBJECT label2 AS label WITH ;
Caption = "Position Top", ;
Height = 25, ;
Left = 12, ;
Top = 132, ;
Width = 72, ;
Name = "Label2"
ADD OBJECT label3 AS label WITH ;
Caption = "Move Speed", ;
Height = 25, ;
Left = 12, ;
Top = 192, ;
Width = 72, ;
Name = "Label3"
ADD OBJECT spnspeed AS spinner WITH ;
Height = 25, ;
Left = 85, ;
Top = 192, ;
Width = 72, ;
Value = 1000, ;
Name = "spnSpeed"
ADD OBJECT command3 AS commandbutton WITH ;
Top = 72, ;
Left = 132, ;
Height = 37, ;
Width = 96, ;
Caption = "Show Balloon", ;
Name = "Command3"
ADD OBJECT spnleft AS spinner WITH ;
Height = 24, ;
Left = 97, ;
Top = 161, ;
Width = 60, ;
Value = 50, ;
Name = "spnLeft"
ADD OBJECT label4 AS label WITH ;
Caption = "Position Left", ;
Height = 25, ;
Left = 12, ;
Top = 161, ;
Width = 72, ;
Name = "Label4"
ADD OBJECT command2 AS commandbutton WITH ;
Top = 72, ;
Left = 252, ;
Height = 37, ;
Width = 96, ;
Caption = "Hide Genie", ;
Name = "Command2"
ADD OBJECT command4 AS commandbutton WITH ;
Top = 144, ;
Left = 240, ;
Height = 25, ;
Width = 37, ;
Caption = "Up", ;
Name = "Command4"
ADD OBJECT command5 AS commandbutton WITH ;
Top = 192, ;
Left = 240, ;
Height = 25, ;
Width = 37, ;
Caption = "Down", ;
Name = "Command5"
ADD OBJECT command6 AS commandbutton WITH ;
Top = 168, ;
Left = 204, ;
Height = 25, ;
Width = 37, ;
Caption = "Left", ;
Name = "Command6"
ADD OBJECT command7 AS commandbutton WITH ;
Top = 168, ;
Left = 276, ;
Height = 25, ;
Width = 37, ;
Caption = "Right", ;
Name = "Command7"
PROCEDURE Unload
RELEASE oGenie
RELEASE oAgent
ENDPROC
PROCEDURE command1.Click
oGenie.Speak(ThisForm.Text1.Value)
ENDPROC
PROCEDURE cmdmove.Click
*-- Move the character to the location indicated in the
*-- spinners.
oGenie.MoveTo(ThisForm.spnLeft.Value, ;
ThisForm.spnTop.Value, ThisForm.spnSpeed.Value)
ENDPROC
PROCEDURE command3.Click
*-- Show or hide the text balloon used when speaking.
IF this.caption = "Hide Balloon"
oGenie.Balloon.Visible = .f.
this.caption = "Show Balloon"
ELSE
oGenie.Balloon.Visible = .t.
this.caption = "Hide Balloon"
ENDIF
ENDPROC
PROCEDURE command2.Click
*-- Show or hide the character
IF this.Caption = "Hide Genie"
oGenie.Hide
this.Caption = "Show Genie"
ELSE
oGenie.Show
this.Caption = "Hide Genie"
ENDIF
ENDPROC
PROCEDURE command4.Click
*-- Move the character up, relative to its current
*-- position.
oGenie.MoveTo(oGenie.Left, oGenie.Top - 50,;
thisform.spnSpeed.Value)
ENDPROC
PROCEDURE command5.Click
*-- Move the character down, relative to its current
*-- position.
oGenie.MoveTo(oGenie.Left, oGenie.Top + 50,;
thisform.spnSpeed.Value)
ENDPROC
PROCEDURE command6.Click
*-- Move the character left, relative to its current
*-- position.
oGenie.MoveTo(oGenie.Left - 50, oGenie.Top,;
thisform.spnSpeed.Value)
ENDPROC
PROCEDURE command7.Click
*-- Move the character left, relative to its current
*-- position.
oGenie.MoveTo(oGenie.Left + 50, oGenie.Top,;
thisform.spnSpeed.Value)
ENDPROC
ENDDEFINE
*
*-- EndDefine: form1
**************************************************
*-- Code ends here
Additional query words: kbVFp600 kbAnimantion kbinterop msagent
Keywords: kbhowto KB191950