Implement Microsoft Agent in VC ++

Source: Internet
Author: User

People who have used office97 or Office2000 will know that there is a cute Office Assistant in the office software, which can make some interesting tips and Animation To make user operations more user-friendly and interesting. Just like the office assistant "eye Xia", Microsoft provides the agent software development technology, known as "Microsoft Agent", which supports Chinese characters. Strong Interaction Function With the characteristics of human nature, not only can give interesting prompts, but also give humorous animation effects, the use of "Microsoft Agent" can make your Program A lot of colors are added.

"Microsoft Agent" is a set of ActiveX control. You can download the relevant program msagent.exeat http://www.microsoft.com/msagent/default.asp, and install it as needed. The animation files of the agent support single-structure Role files (*. ACS) and Multi-structure Role files (*. ACF). This article describes the former. The execution result is as follows:

If you have not installed the role James, you can download it from http://www.msagentring.org/chars.htm.

Implementation Method:

1. Create a project myagent:

Create a dialog box-based VC ++ project myagent;

2. Add the ActiveX component: Microsoft Agent in the window:

After "Microsoft Agent" is correctly installed, the ActiveX control is added to the system for use. Currently, the maximum version of this ActiveX control is 2.0, that is, "Microsoft Agent control 2.0 ";

3. Start Using Microsoft Agent"

1. Define member variables

Use classwizard to define the member variable m_sysagent for Microsoft Agent, that is:

Cagentctlex m_sysagent;

2. Define other variables

It is preferred to add the following header file in the header file of the window, that is:

# Include "agentctlcharacters. H"

# Include "agentctlcharacterex. H"

# Include "agentctlrequest. H"

Then define the protection variable:

Cagentctlcharacters m_characters;

Cagentctlcharacterex m_ex;

Cagentctlrequest m_request;

3. Start using:

You can load an animated file in the initialization form, that is, add the following to cmyagentdlg: oninitdialog ():Code:

Colevariant IV ("0 ");

M_characters = m_sysagent.getcharacters ();

M_request = m_characters.load ("Jame", colevariant ("C: \ WINDOWS \ msagent \ chars \ James. ACS "));

M_ex = m_characters.character ("Jame ");

M_ex.show (IV );

To uninstall an animation file when the window is closed, add the following code when closing the window:

M_characters.unload ("Jame ");

4. Control animation files:

in a program, you can completely control the animation file to complete various actions, such as display, hide, text prompt, and action. You can call show (), hide (), speek () is completed with play. If you want to use an animation, you can use the following command:

m_ex.play (" Greet ");

For specific operations, see the Help file of the control or visit http://www.microsoft.com/msagent/default.asp.

The "Jame" animation mainly provides the following actions:

Acknowledge (acknowledge)

Alert (warning)

Announce (statement)

Blink)

Confused)

Congratulate (congratulations)

Decline (reject)

Explain)

Lookdown)

Lookup (move up)

Movedown (move down)

Moveleft (move to left)

Moveright (move to the right)

Greet (Greetings)

Read)

Write)

Search)

Restpose (restore the initial state)

Think)

......

For more information, see: http://www.msagentring.org/chars.htm

This article only mentions a small part of agent functions. You can implement other functions on your own. For more information, see.

Note: The sample program is compiled in Windows XP + visual c ++ 6.0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.