Pop-up Menu Support

Microsoft Agent includes a pop-up menu (also known as a contextual menu) for each character that the server displays automatically when a user right-clicks the character. This menu displays some standard commands managed by the server, but it also enables you to add and remove commands that your client application defines. The current input-active client's commands appear, provided that their Caption and Visible properties have been set. If the Enabled property has been set to True, the command appears enabled; if False, the command appears disabled (unavailable appearance). You define the access key for the entry by including an ampersand (&) before the text character of the Caption text setting. A separator appears before these commands. To create entries on a character's pop-up menu, define a Commands collection object and set the Caption and Visible properties of the commands. Note that menu entries do not change while the menu displays. If you add or remove commands or change their properties, the menu displays the changes when the user redisplays the menu.

The captions of any other clients (non-input-active) appear after another separator. To appear in the list, the Caption and Visible properties of their associated Commands object must be set. An ampersand in the text setting of the Caption property defines the access key for the entry. It is possible that access keys for menu items may be non-unique; however, this cannot be avoided. Separators appear only when there are items in the menu to separate. If no entries exist, the separator for that group does not appear.

Because the server provides the right-click pop-up menu as a standard service, avoid defining your own pop-up menu on the right-click event. However, if you define your own character, you can disable the server's pop-up menu by using the Microsoft Agent Character Editor. This enables you to support your own interface for the right-click action for your character. However, the pop-up menu cannot be disabled by a client application.

When the user selects a command from a character's pop-up menu or the Commands Window, the server triggers the Command event of the associated client and passes back the parameters of the input using the UserInput object.

The server also provides a pop-up menu for the Microsoft Agent taskbar icon. This menu provides the user access to all connected characters, and automatically assigns access keys for the characters based on the first letter of the character name. The menu also includes an entry that provides user access to the Microsoft Agent property sheet. You cannot modify the contents of the Microsoft Agent taskbar pop-up menu.

When the user chooses Exit from the Microsoft Agent taskbar icon pop-up menu, the server notifies the user that applications (clients with existing connections to the server) may not operate correctly and requests confirmation. If the user confirms shutting down the server, the server sends all client applications a Shutdown event. Your application becomes responsible for how it handles this state. Client applications cannot stop or cancel server shutdown.

If the server gets a request to restart after being shut down, for example, because a new client connects, the server partially reloads in suspended state, displaying the "suspended" Microsoft Agent icon in the taskbar notification area. Microsoft Agent also displays a message box indicating that the current application has requested to restart its services and offers to restart the server. (It also includes an option for the user not to be prompted again.) If the user chooses to restart, the server restores in its full operation and sends clients the Restart event. If the user chooses not to restart, the server remains its suspended state until all its clients close their connections or the user explicitly chooses to exit it again.