Inside the Visual FoxPro 8.0 Task Pane Manager 

 

Beth Massi, www.BethMassi.com

April 2003

Applies to:
   Visual FoxPro 8.0

Summary: Learn about the Visual FoxPro 8.0 Task Pane Manager: how the built-in panes work, how the Task Pane Manager architecture is structured, and how to create your own, including complex, dynamic task panes that incorporate XML data, link to Internet resources, run Visual FoxPro code, and display rich controls. Finally, learn to publish your task panes and share them with others. (38 printed pages)

Contents

Introduction
Task Pane Manager
Customizing Panes
Creating Your First Task Pane
Task Pane Manager Architecture
Advanced Techniques
Publishing and Installing Task Panes
Conclusion

Introduction

The Visual FoxPro Task Pane Manager is a new enhancement to the Visual FoxPro version 8.0 Integrated Development Environment (IDE). It aids in the Visual FoxPro development experience. The Task Pane Manager manages individual panes that are used to make essential everyday tasks easy to accomplish. The panes aid in discovering new and existing features, expose wizards and tools to accomplish simple tasks, display Help, present samples, and deliver dynamic content to the Visual FoxPro desktop. The Task Pane Manager is similar to the Visual Studio start page, but as you will soon see, it is much more flexible and, of course, extensible.

The panes can consist of XML/XSLT Dynamic HTML, display entire Web pages, call XML Web services, or contain Visual FoxPro controls. The panes are loaded into the Task Pane Manager, whose architecture supports add-in panes and pane customizations. Third-party vendors can then provide specialized dynamic content, Help, and install applications or tools through their own task pane. This also means that Visual FoxPro developers can easily modify existing panes to suit their needs or create and share task panes with one another to achieve the ultimate in rapid application development.

In this article, I will introduce you to the Task Pane Manager and briefly explain how the set of task panes that Microsoft provides work. I will show you how to quickly create simple task panes and how to customize existing panes. Then I will walk you through the Task Pane Manager architecture and discuss how to create complex, dynamic task panes including ones that call XML Web services, format and display XML data, link to Internet resources, run Visual FoxPro code, and display rich controls. I will also show you how to publish your task panes and distribute them to other developers.

Task Pane Manager

You can open the Task Pane Manager from the Visual FoxPro Tools menu or by clicking the Task Pane icon located on the Visual FoxPro standard toolbar. The Task Pane Manager is basically a container that displays content inside a pane. It is a resizable form with two sections—the toolbar, and the pane area (Figure 1). The toolbar is always displayed and contains user-customizable pane link buttons that load the specified panes into the pane area. There are also buttons to the Task Pane Manager Options, a refresh button, which reloads the current pane, and a menu that displays the rest of the pane links that will not fit on the toolbar. The pane area is where the specific pane content is displayed.

Figure 1   The Visual FoxPro Task Pane Manager with the Start pane displayed

Many default panes ship with Visual FoxPro 8.0. They help you accomplish tasks quickly by providing access to RAD tools, wizards, and sample code. Some pull dynamic content from the Internet directly to your desktop so that Microsoft can keep you up to date with product-related information, community news, new samples, whitepapers, and XML Web service information. This type of content is downloaded to the panes based on your caching settings.

Each task pane stores any content or code that it creates or needs in its pane cache. The pane cache for a particular pane is located in a folder based on its ID under your HOME(7) folder, that is, \Documents and Settings\UserName\Application Data\Microsoft\Visual FoxPro 8\TaskPane\PaneCache\PaneUniqueID. For dynamic panes, this is also where content from the Internet is downloaded and stored. By default, the Task Pane Manager checks for new Internet content every time you open the Task Pane Manager. You set this option from the Task Pane Manager Options accessible from the Options button on the toolbar. Select Task Pane Manager in the tree view to reveal global settings for the Task Pane Manager (Figure 2). In this section, you can also specify which pane to display when you open the Task Pane Manager as well as whether it should open automatically when you start Visual FoxPro. By default, each pane that downloads Internet content pays attention to the global Check for new Internet content setting specified here.

Figure 2   The Task Pane Manager Options display global options as well as options specific to each pane.

You can control how often Internet content is downloaded into your pane cache by selecting from the following options:

  • Every time you start the Task Pane Manager
    Select this option if you are online, but you have a slower connection. New content is downloaded only once every session.
  • Every time the pane is loaded
    Select this option if you are online with a constant, higher-speed Internet connection. Every time the pane is loaded, content is downloaded, and the cache is always refreshed.
  • Every x days
    Select this option if you have Internet access, but have a slow connection. Only new content is pulled for a pane if X days or more have elapsed.
  • Never
    Select this option if you are offline and do not have Internet access. The pane content always pulls from the cache.

You can modify this setting for individual panes by selecting the pane name from the tree view and specifying the appropriate option. Some of the task panes that Microsoft distributes have additional options that are pane specific. If there are options to configure, they will appear on the right when the pane is selected from the tree view. For instance, panes that have multiple sections can be configured to display only the sections you want. The section names appear as check boxes that are all selected by default.

Start Task Pane

The Start pane is displayed the first time the Task Pane Manager is opened. This pane contains four sections: Start, My Tools, Recent Projects, and Recent Databases. It also contains a link at the bottom that opens the Task Pane Manager Options. The Start section displays content from an XML file on the Internet. It can contain links to Help topics, white papers, wizards, and links to other Web sites. When Microsoft updates the content, it is downloaded to this section of the Start pane periodically depending on your caching settings. The My Tools section provides quick access to tools, utilities, and script you frequently run while inside the IDE. Click Manage to open the My Tools application and define your tools. When you close the form, the pane refreshes, and the list of your tools appears in a drop-down list. Select a tool from the list, and click Run to run the tool.

Recent Projects and Recent Databases sections display the projects or databases that you have most recently opened. This is referred to as an MRU list (most recently used). These sections read and display this information from your FoxPro resource file (FOXUSER). These sections list the project/database name, path, and date last opened. Click the project or database name to open that project or database. Click the Open Project or Open Database to open a project or database not in the list. Click New Project or New Database to create a new project or database.

The Start pane is an HTML pane and can have any HTML or Dynamic-HTML element rendered in the pane area. This will be explained later in this paper, but for now just know that panes that use mark-up languages are hosted inside the Internet Explorer Web Browser ActiveX control. So when a hyperlink is activated, Visual FoxPro can intercept the event and run code instead. This is how applications, Help files, and dialog boxes are called when a hyperlink is clicked. For example, Manage runs the My Tools application. For more information, see "Using Built-In Handlers" later in this paper.

Community Task Pane

The Community pane displays valuable community content from reputable providers on the Internet. It lists community links, downloads, articles, training, topics and news from FoxCentral, Universal Thread, and the FoxPro Wiki under the News subheading. By default, only FoxCentral is displayed. You can select the other providers and provide the user name and password to the Universal Thread in Task Pane Options. (You need to register for the Universal Thread before you can access the content it provides; however, basic membership is free.) The items can be sorted in ascending and descending orders by date, title, or provider by selecting the appropriate drop down lists above the news items. Expand a news item to reveal its description by clicking the plus sign (+) next to the item. To open the item, click the title, which is a hyperlink that opens the item URL in a new browser window.

The Community pane is an XML pane that calls XML Web services to retrieve content in the form of XML data. If you right-click the pane area and select View Source from the shortcut menu, XML is displayed (Figure 3). The XML data returned from each of the providers is then transformed into a standard format and is displayed together on the pane with a static XSL file located in the pane cache called News.xsl. XSLT provides sorting on the XML data.

Figure 3   The Community pane displays XML data retrieved from XML Web services.

Environment Manager Task Pane

The Environment Manager pane displays environment sets and associated projects you set up using a tool called the Environment Manager. This is where you can organize environment settings into groups and associate projects with them. When you open a project from this pane, it runs the environment settings before the project opens. The Environment Manager application is located in the Visual FoxPro home directory and is called EnvMgr.app. It stores the environment sets you create in a table located in your HOME(7) folder and is called EnvMgr.dbf. Like the Community pane, the Environment Manager is also an XML pane. However, instead of getting XML data from Web services on the Internet, it selects data from the EnvMgr.dbf table into a cursor and returns XML using the CURSORTOXML function. It then displays the XML data using static XSL file located in the pane cache called Envmgr.xsl.

Solution Samples Task Pane

The Solution Samples pane presents a searchable list of all the Visual FoxPro solutions and samples contained in the Samples\ folder under the Visual FoxPro home directory. It displays information about the samples stored in two data tables: one is located in the Samples\Solution folder and is called Solution.dbf, and the other is located in the pane cache called Solutionaddins.dbf. Solution.dbf contains information about the examples that Microsoft ships with Visual FoxPro. Solutionaddins.dbf is where sample add-ins you install are kept. You can have code samples other users provide included here if a solution add-in manifest is distributed with the sample code. Click the Install Sample button at the bottom of the task pane to locate the add-in manifest file. The manifest file is an XML file that contains information about the sample and to what category it belongs.

<solutions vendor="VendorName" name="SolutionSetName">
    <category key="CategoryKey">
        <text>CategoryName</text>
        <image>PaneCacheImageFileName</image>        
        <solution key="SampleKey" parent="CategoryKey">
            <text>SampleName</text>
            <type>SampleType</type>
            <file>FileNameWithoutPath</file>
            <description><![CDATA[DescriptionText]]></description>
        </solution>
    </category>
</solutions>

Use this format to add a solution to a new or existing category by setting the parent attribute value of the solution element to refer to the key attribute on the category element. The description element in the solution node can be a CDATA section so that HTML can be displayed in the description section of the sample. The image element references an image name contained in the Microsoft.Solutions pane cache. If you do not specify an image, a default image is displayed. The sample type and file elements are used to determine how to execute or display the sample when it is run or the code is viewed. The values for the type element are listed in the following table.

Value Meaning
F Form
R Report
Q Query
V View
A Application
C Program (PRG)
P Project
M File is opened using MODIFY FILE command
D Open Database
S Open the file with ShellExecute

For example, You download a sample that includes a manifest and place it in the folder \Samples\Solutions\MySamples\. The manifest file is as follows:

<?xml version='1.0' encoding='windows-1252' standalone='no'?>
<solutions vendor="Massi" name="MySamples">
    <category key="Massi_Samples">
        <text>Beth's Cool Samples</text>
        <image>frm</image>
        <solution key="mysample" parent="Massi_Samples">
            <text>My Cool Sample</text>
            <type>F</type>
            <file>mysample</file>
            <method></method>
            <description><![CDATA[See how easy it is to create a manifest 
                          and install sample add-ins! Now <a
                          href="vfps:linkto?url=http://www.bethmassi.com">
                          check out my website</a> for more samples!]]>
            </description>
        </solution>
    </category>
</solutions>

In the Solution Samples pane, click Install Sample and navigate to the manifest file. The sample is added to the list of searchable sample categories (Figure 4).

Figure 4   Use sample add-in manifest files to install third-party samples directly into the task pane.

Sample add-ins can be removed individually by expanding the sample in the tree and clicking the Remove image link on the right.

The last section of the Solution Samples pane is a dynamic section that pulls data from a file on the Internet. When Microsoft updates this file with links to sites that provide sample add-ins, the links are displayed in this section.

The Solution Samples pane is one of the more interesting panes included with the Task Pane Manager. It is an HTML pane that is controlled by a program located in the pane cache called Solutions.prg. This program also performs searches and updates the pane using Dynamic HTML by manipulating XML results stored in an Internet Explorer data island. The XML in the data island is set as the data source of a results table that is displayed under the search text box. This demonstrates how you can use Visual FoxPro code to interact easily with HTML task panes, taking advantage of the Internet Explorer Document Object Model (DOM). Later you will see an example of how to interact with Internet Explorer from Visual FoxPro code. For more information about data islands, Dynamic HTML and the DOM in Internet Explorer, see Web Development and the MSXML 4.0 SDK in the MSDN Library.

XML Web Services Task Pane

Because of Microsoft's push for the programmable Web, it is no surprise XML Web services are given a much higher profile in this version of Visual FoxPro. More tools to help you manage, publish and register XML Web services are accessible from the XML Web Services task pane. Here you can access XML Web service tools and explore service methods. Select an XML Web service from the drop-down list to test its methods and view proxy code. There is also a dynamic section at the bottom of this pane that pulls data from a file on the Internet that contains the latest Microsoft information regarding XML Web services.

The XML Web Services pane is an HTML pane that displays information on your registered XML Web services stored in the table Foxws3.dbf located in the Visual FoxPro home directory. Data is selected from this table in the form of XML and is transformed into a list of available services. When you select a service from the list, code is executed that runs the XML Web service tools.

Filer Task Pane

Filer is a tool that dates back to the early days of Visual FoxPro. It helps you locate and edit files on your computer. Its functionality is exposed in a COM library called Filer.dll that contains the application logic, but no user interface. You can use the library in your applications when you create a user interface. The Filer task pane does just that by providing a user interface that is accessed through the Task Pane Manager.

The Filer task pane (Figure 5) is an example of using rich Visual FoxPro controls on a task pane. The controls are hosted on a container class that inherits from the Task Pane Manager PaneContainer class and is stored in a class library called Filer.vcx that is located in the pane cache. The PaneContainer class sets up the container to work with the Task Pane Manager. When you create task panes that use rich Visual FoxPro controls, you inherit from this class.

Figure 5   The Filer pane inherits from the PaneContainer class and contains rich Visual FoxPro controls.

Minesweeper Task Pane

The Minesweeper pane is a Visual FoxPro version of the Windows minesweeper game. This pane also displays rich Visual FoxPro controls. However, instead of the pane definition being stored in a class library file (.vcx), it is defined in a program file called Mines.prg located in the pane cache. This program also contains a great example of how to use the Collection class in Visual FoxPro.

Customizing Panes

You can easily change the order of task pane link buttons on the Task Pane Manager toolbar or reorder how content appears in panes themselves. It is also easy to change the names of the panes and the hotkeys on the pane link buttons or remove task panes you never use.

Customizing the order of the pane link buttons can be done from the Task Pane Manager Options. Click the Options button on the toolbar, select the pane name from the tree view on the left, and then use the Move Up and Move Down buttons above the tree to position the pane in the desired location. Click OK to close the form, and the pane link buttons appear in the order you specified.

To change the name and hotkeys of the link buttons on the Task Pane Manager toolbar, use the Pane Customization form (Figure 6). This form is also where you create, install, delete, edit, and publish task panes. You use this form throughout most of this article so you should become familiar with its functionality. This form is accessible from the Task Pane Manager Options by selecting the Task Pane Manager>Customize category from the tree view and then selecting the Customize Panes button on the right. This form contains a tree view of pane names on the left and pane content information on the right. This form is also modeless so that you can access the Task Pane Manager at the same time. You can click Apply at the bottom of the form and immediately see your changes in the Task Pane Manager without having to close the customization form. This is handy when building your own panes, as you will see later.

Click here for larger image

Figure 6   The Pane Customization form is where you create, install, delete, edit and publish task panes.

You can change the name and hotkey of the task pane in the Name field of the General tab. Use the \< syntax in the name to specify the hotkey. For instance, the Name box of the Start pane says \<Start; that displays "Start" on the pane link button indicating ALT+S as the hotkey for the pane. Type a new name and click Apply to update the Task Pane Manager toolbar with your changes.

There is also a tree view in the center of the Pane Customization form that contains the names of the pane content subsections. Pane types that are XML or HTML can have multiple sections. We'll talk more about content subsections later, but basically subsections allow task panes to interact with data from multiple sources and present that data on a single pane. The section content can be merged and displayed in a unified way, like the Community pane, or the content can be displayed in its own area of the pane, like the Start pane.

Content sections can be visibly reordered on panes that display each of them in their own section of the pane (Figure 7). For instance, the Start pane has four sections to its pane that are displayed in distinct areas on the pane itself. Reorder the content by selecting the section from the content tree view and clicking the up/down arrows on the content toolbar to specify the new location. Then click Apply at the bottom of the form to update the task pane with your changes.

Click here for larger image

Figure 7   You can reorder specific sections of content on a task pane using the Pane Customization form.

If there are panes you never use, you can remove them from the Task Pane Manager. The task panes that Microsoft distributes cannot be permanently deleted; however, you can mark these panes as inactive. Select the pane name from the pane tree view and click the Inactive check box at the bottom left of the Pane Customization form. When you click Apply, the pane is not visible from the Task Pane Manager toolbar or the Task Pane Options.

You can use the Pane Customization form to make modifications to any other information the panes use, not only simple customizations. You will be looking at the details of this form as you create your own task panes, but feel free to modify other settings and explore how the panes work. If you need to, you can restore the Task Pane Manager to its original content by clicking the Restore to Default button on the Task Pane Manager Options under the Task Pane Manager>Customize category.

Creating Your First Task Pane

The simplest type of task pane you can create is one that displays a Web site on the Internet or your company's intranet. You can display sites you use most often when working in Visual FoxPro as task panes so that they can be directly available from the Visual FoxPro IDE.

To create a task pane, open the Pane Customization form, and select New on the pane toolbar. A dialog box appears that prompts for your vendor name and the pane's unique ID (Figure 8). By default, the unique IDs for panes take the form of VendorName.Sys(2015). The Visual FoxPro function SYS(2015) returns a unique 10-character name. When you type your vendor name, the form automatically places the name as the prefix of the unique ID, for example, MyCompany._0VC0UV6D2. You can type another ID that is easier to remember, but it needs to be unique if you plan to distribute the panes to other developers. This is because when you make changes to your panes and redistribute them to people, the Task Pane Manager will upgrade or install the pane based on its unique ID.

Figure 8   Set up a Web Page task pane by first specifying your vendor name and unique ID.

For the first task pane, type Search MSDN, and select Web Page in the Pane Type box. Then click OK to see the pane added to the pane tree view. A Search MSDN node is also created in the content tree view on the right, and the General tab is displayed. You can select an image to display on the Task Pane Manager by clicking the Select Image button; otherwise, a default image is provided. To specify the Web address, click the Data tab and enter the URL in the text box provided. In this case, use, http://www.google.com/microsoft.html. Click Apply, and select the Search MSDN pane link to display the Web site. Links you click inside this type of pane navigate the entire pane to the selected URL.

This type of pane is meant to provide easy access to Web sites from inside the Visual FoxPro IDE, but you will notice that the Task Pane Manager does not have all the typical Web browser user interface controls, namely, the Web address bar. However, you can activate the shortcut menu to access back/forward movement as well as the source and properties of the pages. Because of these limitations, instead of displaying the site directly inside a task pane, it may be more useful to display a list of hyperlinks that open the browser instead. You can create an HTML task pane that does just that by displaying static content from an HTML file on your computer.

The HTML file can be as fancy as you want. However, for the purpose of this example, You will just create a simple HTML file in Notepad called Static.htm.

<html>
<head>
<title>My Search Links</title>
</head>
<body>
<h2>My Search Links</h2>
<p>The HTML text here came from a file on my computer called static.htm. 
It was copied into the pane cache when I created the pane in the Pane 
Customization form. This means when I distribute my pane, this file will 
also be distributed. You can verify what files are being distributed in 
the pane cache by selecting the <b>View Files</b> option button at the top 
right of the Pane Customization form.</p>
<p>
<a href="vfps:linkto?url=http://www.google.com/microsoft.html">Search MSDN 
with Google</a>
</p>
<p>
<a href="vfps:linkto?url=http://search.microsoft.com/advanced_search.asp?site
id=us/dev">Search MSDN with Microsoft</a>
</p>
</body>
</html>

Now create a new task pane called Search Links, and select HTML in the Pane Type box. To use the static HTML file, on the Data tab select File as the Source and locate the Static.htm file on your computer. When you specify static files as part of a pane, they are copied to the pane cache automatically. When you publish panes, the files in the pane cache are automatically packaged and distributed. You can verify which files are being distributed in the pane cache by selecting the View Files option button at the top right of the Pane Customization form. After the file is copied to the cache, you should make modifications to the cache copy from the files view by selecting the Edit button; otherwise, you can remove and read the file (Figure 9).

Click here for larger image

Figure 9   The files view allows you to manage all the static pane files that are included in the pane cache.

By now you are probably noticing the strange syntax on the hyperlinks in this file. The syntax vfps:linkto?url= prefixes the actual URL. This is a built-in feature of the Task Pane Manager called a handler. You will take a much deeper look at all the built-in handlers as well as how to define your own when the Task Pane Manager architecture is discussed. For now, just know that this syntax tells the pane to open the link in a new browser window. When you click Apply on the Pane Customization form, you will see the pane display the static HTML file. If you click the hyperlinks, the URLs open in a new browser window and the task pane remains fixed (Figure 10).

Click here for larger image

Figure 10   The Task Pane Manager provides a set of built-in handlers that allows you to open a new browser window from a hyperlink.

The preceding material is really the tip of the iceberg when it comes to all the ways you can create task panes. You understand the basics of creating simple panes, but up until now the content has been, well, boring. However, to create dynamic, flexible, and feature-rich task panes such as the ones Microsoft provides, you need to review some of the architecture of Task Pane Manager and the internals on how it renders task panes.

Task Pane Manager Architecture

The Task Pane Manager application resides in the Visual FoxPro home directory (HOME()) and is called Taskpane.app. As you have already seen, pane-specific content is stored in the pane cache that the Task Pane Manager reads to load panes. The cache can contain static files necessary to run the pane and content downloaded from the Internet, depending on the type of pane and its functionality. By default, the pane caches are located under the HOME(7)+TaskPane\ working folder. Individual panes store files in a folder based on their unique ID: HOME(7)+Taskpane\PaneCache\+PaneUniqueID. For instance, by default the Solution Samples pane stores its files in: \Documents and Settings\UserName\Application Data\Microsoft\Visual FoxPro 8\TaskPane\PaneCache\Microsoft.Solutions\.

You can change the Task Pane Manager's working folder and the pane cache folder from the Task Pane Manager Options. The Task Pane Manager application also reads tables located in the working folder called TaskPane.dbf and PaneContent.dbf that stores information about the installed panes and their content subsections. When you modify panes from the Pane Customization form, you are modifying data in these tables.

The system variable _TASKPANE specifies the path and file name for the Visual FoxPro Task Pane Manager. By default, this path is the Visual FoxPro home directory, and the file name is Taskpane.app. However, you can specify a path and file name for _TASKPANE on the File Locations tab in the Visual FoxPro Options dialog box.

You can pass a string parameter into the Task Pane Manager that is the unique ID of the pane to open it automatically.

DO (_TASKPANE) WITH "MICROSOFT.FILER"

You can also pass an option "-s" to open the Pane Customization form directly.

DO (_TASKPANE) WITH "-s"

Additionally, when the Task Pane Manager is open in the Visual FoxPro IDE, the global variable _oTaskpane is exposed.

All the source code for the Task Pane Manager application is included in the Xsource.zip file contained in the \Tools\XSource\ folder under the Visual FoxPro home directory.

Rendering Panes with Rich Content

The Task Pane Manager can render panes that contain Visual FoxPro controls also referred to as rich content. You have already seen a couple examples of this: the Filer Pane and the Minesweeper Pane. To create a pane with Visual FoxPro controls, you inherit from a class included with the Task Pane Manager called PaneContainer. This class is available when the Task Pane Manager is running, so it does not have to be distributed. You can also edit the pane code directly from the Pane Customization form. You can make this class available at design time in the Visual FoxPro IDE if you extract the class library FoxPane.vcx from the TaskPane folder in the Xsource.zip file.

The base class of the PaneContainer is the Container class. You can place any type of control onto a pane. You are not required to override any of the methods in the PaneContainer class, but there are a few useful methods to note.

OnRender(oPane, oContent)—This method is called when the container is rendered. It passes the Pane and Content objects. The Pane object holds instance data for the task pane that is being rendered in the Task Pane Manager, while the Content object holds a reference to the particular content section. Because there is only one content section for rich content panes, this method is called only once on the PaneContainer class. However, the Pane and Content objects are also available when rendering HTML and XML panes, which can contain multiple content subsections.

The Pane object exposes the following properties.

Property Description
PaneTable The name of the table that stores the pane metadata (TaskPane.dbf)
PaneContentTable The name of the table that stores the pane content metadata (PaneContent.dbf)
CacheDir The path to the user's task pane working folder
CacheHomeDir The path to the user's pane cache working folder

The Content object exposes the following important methods and properties:

GetOption(cOptionName, xDefaultValue)—This method returns the value of an option specified on the Task Pane Options for the content section. With this method, you can optionally specify the default value to return if the option is empty. All options values are returned as strings, unless xDefaultValue specifies a different data type, in which case the resulting value will be converted to that type before returning.

Property Description
CacheDir The name of the user's pane cache directory
ContentTile The name of the content section
UniqueID UniqueID of the content section
TaskPaneID UniqueID of the pane in which the content section belongs
User User data that is contained in the User field in the PaneContent table

OnResize()—This method is called whenever the Task Pane Manager window is resized. It gives you a chance to resize the controls on your pane container.

OnKeyPress(nKeyCode, nShiftAltCtrl)—This method is called when your pane has focus and a key is pressed. It has the same parameters as a form KeyPress event. Put code in this method to trap keystrokes from your pane. If you handle the keystroke and then return .F. (false), the keystroke is not processed by the Task Pane Manager. Otherwise, return .T. (true) so it is handled normally. For example:

FUNCTION OnKeyPress(nKeyCode, nShiftAltCtrl)
    IF nKeyCode == 27
      MESSAGEBOX("Escape Pressed")
      RETURN .F.
    ELSE
      RETURN .T.
    ENDIF
 ENDFUNC

Rendering Panes with HTML/XML Content

The Task Pane Manager can render panes that contain XML and HTML content by using the Internet Explorer Web Browser ActiveX control. This control displays HTML or XML content that is created by the pane based on the settings in the Pane Customization form. There are many ways to create HTML and XML panes, but typically these panes pull content from multiple data sources such as static files or tables on the local computer, files on the Internet/intranet, XML Web services, or data generated from code. It displays that data in a single pane. You do this by first creating pane content subsections and defining the method of obtaining data for each of them from the Data tab on the Pane Customization form.

Typically, this data is returned as XML, but it can also be HTML or static text. Then you can optionally specify a transformation, which is a way of changing the format of the data. The transformation is typically defined as XSLT and transforms the data into HTML or a standard XML format. Then these content subsections can be displayed in their own area of the pane or can be displayed together depending on the final transformation.

The way the rendering process works is that the content data from each section is obtained as specified on the Data tab of the Pane customization form and is transformed as specified on the Transform Data tab. The resulting data for all the subsections is placed in the data format as specified by the Data tab on the root content and its final transformation is run before the task pane is displayed. Figure 11 depicts the order of steps involved in the rendering process for a pane with three content subsections.

Figure 11   The rendering process for an XML or HTML pane with three content subsections defined.

Internally, the Task Pane Manager creates merged data from all the sections' transformed data that is used as the data for the root. The format of the data depends on how the content is specified on the Data tab for the root content. By default, the Source box on the Data tab is set to Static Text and the following is specified:

<!-- CONTENT -->

This indicates that internally the merged data format is a concatenation of all the subsection content. For example, if each subsection above produced the following data after its transformation:

This is my section <b></b>

where X**is the number of the section, you end up with the following merged data as the data for the root content:

This is my section <b>1</b> 
This is my section <b>2</b>
This is my section <b>3</b>

Then, if specified, the final root transformation is applied to this data. The final transformation typically operates on XML data returned from the subsections. In this case, you can define XML root elements and place the concatenation of the subsection data between these tags.

<MyRootData>
    <!-- CONTENT -->   
</MyRootData>

For example, if each subsection produced the following data:

<MySubsectionData>This is my section </MySubsectionData>

where X**is the number of the section, you end up with the following merged data as the data for the root content:

<MyRootData>
    <MySubsectionData>This is my section 1</MySubsectionData>
    <MySubsectionData>This is my section 2</MySubsectionData>
    <MySubsectionData>This is my section 3</MySubsectionData>
</MyRootData>

Then, if specified, the final root transformation is applied to this data. The Community and Environment Manager panes use merged data in this way.

You can also specify that the format of the merged data should be expressed as XML instead of a simple concatenation by specifying the following as the data for the root:

<MyRootData>
   <!-- XMLCONTENT -->   
</MyRootData>

In this case, the internal merged data is an XML fragment that is placed between the XML root elements you define. The XML fragment for a single subsection has the following format:

<PaneContent id="uniqueid">
       <PaneTitle>Content Subsection Title</PaneTitle>
       <HTMLText>
     <![CDATA[This is where your transformed subsection content is placed]]>
       </HTMLText>
</PaneContent>
   

For example, if each subsection produced the following data after its transformation:

This is my section <b></b>

where X**is the number of the section, you end up with the following merged data as the data for the root content:

<MyRootData>
  <PaneContent id="uniqueid1">
       <PaneTitle>Section 1</PaneTitle>
       <HTMLText>
            <![CDATA[This is my section <b>1</b>]]>
       </HTMLText>
  </PaneContent>
  <PaneContent id="uniqueid2">
       <PaneTitle>Section 2</PaneTitle>
       <HTMLText>
            <![CDATA[This is my section <b>2</b>]]>
       </HTMLText>
  </PaneContent>
  <PaneContent id="uniqueid3">
       <PaneTitle>Section 3</PaneTitle>
       <HTMLText>
            <![CDATA[This is my section <b>3</b>]]>
       </HTMLText>
  </PaneContent>
</MyRootData>

Then, if specified, the final root transformation is applied to this data. This technique is used on the Start, Solution Samples, and XML Web Services task panes. One thing to note: do not be misled by the name of the <HTMLText> element. The data here does not have to be HTML, even though it typically is. This element represents the data from the subsection no matter what the format so you have total flexibility in the way you define your content. Your head may be spinning at this point, but you will see examples using merged data from content subsections when you create HTML and XML task panes.

Using Built-In Handlers

Handlers are a way for Visual FoxPro code to run from HTML and XML task panes. They allow you to specify code to execute when hyperlinks are clicked on the pane and the hyperlink begins with vfps:. You have already seen an example of this when you created our simple static HTML pane that displayed hyperlinks that opened the browser window. For example,

<a href="vfps:linkto?url=http://www.somewhere.com/">Click Me</a>

The vfps:linkto?url= syntax calls a built in handler that opens the browser window to the specified URL. The following handlers are built into the Task Pane Manager and can be used directly from hyperlinks on your task pane:

vfps:refresh—Reloads the pane.
Example: vfps:refresh

vfps:linkto—Opens the browser to the specified URL.
Parameters: url=*cUrl
*Example: vfps:linkto?url=https://msdn.microsoft.com/vfoxpro/

vfps:gotopane—Switches the Task Pane Manager to the specified pane.Parameters: uniqueid=*cPaneUniqueID
*Example: vfps:gotopane?uniqueid=Microsoft.start

vfps:help—Shows Help by topic or ID.
Parameters: ID=cTopicID, Topic=cTopicName
Examples: vfps:help?id=1231106
               vfps:help?Topic=_taskpane

vfps:options—Displays the Task Pane Options for a pane.
Parameters: uniqueid=*cPaneUniqueID
*Example: vfps:options?uniqueid=Microsoft.Start

vfps:message—Displays an informational message box.
Parameters: msg=*cMessage
*Example: vfps:message?msg =This is a message

In addition, if refresh is included as a parameter, the pane is always refreshed upon return from the call. This is useful when the result of the link may affect the pane content, as a refresh can be forced. Refresh can be combined with other parameters, such as:

vfps:message?msg=This is a message&refresh

Refresh can be combined with other parameters on custom handlers as well.

Coding Custom Handlers

Custom handlers are handlers that you write. They are defined on the Handler Code tab of the Pane Customization form. You can create custom actions and handle them from the Visual FoxPro code you write here. For example, to run the following handler you specify your own handler code:

<a href="vfps:Action?Param1=Value1&Param2=Value2">This is my handler</a>

Any action that cannot be handled by the built-in handlers of Task Pane Manager is passed to your handler code. When you specify handler code, the following parameters are passed:

LPARAMETERS cAction, oParameters, oBrowser, oContent

cAction—The action is the text after the vfps: and before any parameters. In the preceding example, the action is Action.

oParameters—This is a collection of the parameters you specified. To retrieve a value, you can either access parameters using the normal Item(x) syntax, or you can call the GetParam function with the parameter name:

Value1 = oParameters.GetParam("Param1")

The benefit of using GetParam is that it wraps the call in a TRY/CATCH so you do not get an error if the parameter doesn't exist.

oBrowser—This holds the object reference to the Window object in the browser control on the pane itself. You can use this to access DHTML methods and properties if necessary, for example:

oBrowser.document.all("SearchResults").style.display = "none"

oContent—This holds a reference to the pane content definition so that you can retrieve option values and the pane cache folder specified on the Task Pane Manager Options. This is the same object that is passed to the OnRender method for rich content panes.

Custom handlers are used on the Microsoft task panes to open files and run applications. For instance, take a look at the following handler code for the Start pane:

LPARAMETERS cAction, oParameters, oBrowser, oContent
LOCAL cFilename

m.cFilename = oParameters.GetParam("filename")
DO CASE
    CASE m.cAction == "doapplication"
        IF EMPTY(m.cFilename)
            m.cFilename = oParameters.GetParam("appname")
        ENDIF
        IF !EMPTY(m.cFilename)
            DO &cFilename
        ENDIF
    CASE m.cAction == "doform"
        IF !EMPTY(m.cFilename)
            DO FORM &cFilename
        ENDIF
ENDCASE 

This code defines handlers for two custom actions: doapplication and doform. The file name (and/or appname) is passed in as a parameter and is used to run the application or the form. If you need this functionality on your pane, you can just copy this code into your handler code.

Displaying Error Messages

Error messages are displayed in HTML and XML panes as a collapsible/expandable region at the top of the pane. The Task Pane Manager automatically displays an error when connectivity problems are encountered with Internet content and XML Web services. Additionally, on the Microsoft panes, configuration errors are displayed when task pane option information needed to run the pane is not specified. For instance, the Community pane needs a valid Universal Thread password and user name to access the UT news. If the option to display UT news is selected, you must supply your password and user name. If you do not, the pane displays a message at the top of the pane area (Figure 12).

Figure 12   Error messages are displayed if there are Internet connectivity problems or if necessary task pane option information is not specified.

You can display custom errors when the Source of the content data specified on the Data tab of the Pane Customization form is set to Script. In this case, the oContent object is passed into the script code, and you can use a method called LogError to display a custom error message. For example, the following code tries to use a table that does not exist and displays an error titled My Error with the exception message, and also creates a link called Options that opens the task pane options for the specified content section:

LPARAMETERS oContent
LOCAL cXML
TRY
    USE Sometable IN 0 SHARED
    CURSORTOXML(Sometable, cXML)
CATCH TO exc
    oContent.LogError("My Error", exc.Message, "Options", ;
                  "vfps:options?uniqueid=Massi.contentsection1")
    cXML = ""
FINALLY
    IF USED("Sometable")
        USE IN SomeTable
    ENDIF
ENDTRY
Return cXML

Specifying Pane Options

Pane options for all the installed panes are displayed in the Task Pane Manager Options and accessed by clicking the pane category in the tree view on the left. If there are options for the pane or pane content subsection, they are displayed on the right.

You can specify option data for a particular pane content section on the Options tab of the Pane Customization form. For XML and HTML pane types, options can be specified only on subsection content. For Web page and Visual FoxPro controls, options are specified on the root content section. When you create an option on the Options tab, you specify the option name used in code, the type of control you want to create, and the caption to display in the Task Pane Options. You can also specify common property values associated with the option controls you create like InputMask, PasswordChar, Width, or any other property you need to assign by adding new properties to the list.

You can access the values of these options in code through the Content object's GetOption method.

Value = oContent.GetOption(cOptionName, xDefaultValue)

With this method, you can optionally specify the default value to return if the option is empty. All options values are returned as strings, unless xDefaultValue specifies a different data type. In this case, the resulting value is converted to that type before returning.

Option values can also be accessed in Web method calls or URLs on the Data tab, such as:

##optionname##

where optionname is the name of the pane option. This merges the value into the call before it is run. For example, on the Data tab if you specify the Source as Web Service, you can use option values in the Method field:

MyWebMethod(##myoption##) 

If the Web method expects a string parameter, enclose it in quotation marks:

MyWebMethod("##myoption##") 

Now that you understand the basic architecture and pane rendering features of the Task Pane Manager, it is time to create advanced task panes. You will be creating configurable HTML and XML panes that display content from files on the Internet, XML Web services, and generate XML data with Visual FoxPro code.

Advanced Techniques

As you probably realize by now, there are many ways you can create task panes. In this section, you will build a complex HTML task pane that calls an XML Web service, pulls dynamic content from a file on the Internet, and runs some custom handler code.

Calling XML Web Services

For our first pane content subsection, you call an XML Web service. You can easily call XML Web services from task panes to retrieve and display content. For instance, if you have a company intranet that provides corporate information through an XML Web service, you can easily host an interface to it inside a task pane. In this same manner, XML Web service creators can publish Visual FoxPro task panes that connect to their services. For this example, you call a publicly available .NET XML Web service that retrieves stock information based on a stock symbol. This is a good example of using custom option information on a pane want to collect the symbol from the Task Pane Options.

On the Pane Customization form, click the New button on the pane toolbar, and type your vendor name, the pane name My HTML, and select HTML as the Pane type. The My HTML root content section is displayed in the content tree. Click the Add button on the content toolbar and type My Stock Quote for the name for the content section. You can also enter a unique ID. In this case, use MASSI.QUOTE as the unique ID for this subsection. On the Data tab, for the Source select Web Service. Calling an XML Web service this way is easy. The Task Pane Manager internally handles setting up the proper proxy code for you. However, if you need to more finely control the SOAP request and response, you can select Script as the Source and enter the code manually. In this case, you also select the box at the bottom of the Data tab, "Source of this content is from the Internet," which indicates to the Task Pane Manager that it should display the caching options for the pane subsection on the Task Pane Options.

In the WSDL URL field, enter the location of WSDL file using the following service:

http://www.webservicex.net/stockquote.asmx?WSDL

Because this is a .NET XML Web service, you can explore the service by navigating your browser to:

http://www.webservicex.net/stockquote.asmx

This service has one method called GetQuote that accepts a stock symbol as a string. You create an option to enter the stock symbol in the Method field as follows:

GetQuote("##stocksymbol##")

To create the option, select the Options tab, and click New to create a new option. In the dialog box that appears, enter the name of the option, "stocksymbol," and a caption, "Stock Symbol" (Figure 13).

Figure 13   You can create custom pane options that appear on the Task Pane Options for your pane.

Now you specify the transformation. This XML Web service returns the stock information formatted as XML. For example, calling the GetQuote method and passing it a parameter of MSFT returns the following:

<StockQuotes>
   <Stock>
      <Symbol>MSFT</Symbol>
      <Last>23.60</Last>
      <Date>2/26/2003</Date>
      <Time>4:01pm</Time>
      <Change>-0.59</Change>
      <Open>24.08</Open>
      <High>24.47</High>
      <Low>23.58</Low>
      <Volume>57314560</Volume>
      <MktCap>252.6B</MktCap>
      <PreviousClose>24.19</PreviousClose>
      <PercentageChange>-2.44%</PercentageChange>
      <AnnRange>20.705 - 32.50</AnnRange>
      <Earns>0.87</Earns>
      <P-E>27.80</P-E>
      <Name>MICROSOFT CP</Name>
   </Stock>
</StockQuotes>

To display this in an HTML pane, you specify a transformation into HTML. You can do this in code, or you can use XSLT. That code or XSLT can come from a location on the Internet, a file on your computer, or even another Web service. For this example, you use static text and type the XSLT style sheet definition. On the Transform Data tab, select XSL as the Type and Static Text as the Source. The following style sheet transforms only the following the elements; Name, Symbol, Last, Change and PercentageChange.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="StockQuotes">
    <TABLE BORDER="0" >
      <xsl:apply-templates select="Stock"/>
    </TABLE>
</xsl:template>

<xsl:template match="Stock">
   <TR>
      <TD>Company</TD>
      <TD>: <xsl:value-of select="Name"/></TD>
   </TR>
   <TR>
      <TD>Symbol</TD>
      <TD>: <xsl:value-of select="Symbol"/></TD>
   </TR>
   <TR>
      <TD>Last</TD>
      <TD>: <xsl:value-of select="Last"/></TD>
   </TR>
   <TR>
      <TD>Change</TD>
      <TD>: <xsl:value-of select="Change"/></TD>
   </TR>
   <TR>
      <TD>Change %</TD>
      <TD>: <xsl:value-of select="PercentageChange"/></TD>
   </TR>
   <TR>
      <TD colspan="2"><a href="vfps:options?uniqueid=MASSI.QUOTE">Change Symbol</a></TD>
   </TR>
</xsl:template>
</xsl:stylesheet>

This style sheet transforms the XML into an HTML table. This HTML is just a fragment of the entire pane. If you recall, the pane transforms all its subsections data before running its final transformation. In this case, the final transformation creates the entire HTML document. To display the subsections of the pane definition in their own sections, you specify that the merged data from the subsections be placed into XML format. You then define the final transformation so you can see the final pane output as you build the rest of the sections.

Select the root content node My HTML from the content tree, and select the Data tab. Select Static Text as the Source, and then enter the following information:

<VFPData>
   <!-- XMLCONTENT -->
</VFPData>

On the Transform Data tab, select XSL as the Type and Static Text as the Source. Then enter the final transformation:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" /> 
<xsl:template match="VFPData">
<HTML>
<TITLE></TITLE>
<HEAD>
<STYLE>
  BODY {
     font-family:verdana;
   font-size:9pt;
   }  
  TD  {font-size:9pt}
  TD.TableTitle
     { 
     font-family: Verdana; 
     font-size: 9pt; 
     font-weight: bold; 
     background-color: #0066CC; 
     padding:2px;
     color: #FFFFFF
     }
  TABLE { margin-bottom:12px  }
</STYLE>
</HEAD>
<BODY>
   <TABLE BORDER="0" width="100%" cellpadding="0" cellspacing="0" >
   <xsl:for-each select="PaneContent">
   <TR><TD class="TableTitle"><xsl:value-of select="PaneTitle" disable-output-escaping="no"/></TD></TR>
   <TR><TD ><xsl:value-of select="HTMLText" disable-output-escaping="yes"/></TD></TR>
   </xsl:for-each>
   </TABLE>   
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>

This defines a style for this pane as well as outputs each of the content section names and their transformed data. In the case of the My Stock Quote section, the transformed data is an HTML table. Click Apply at the bottom of the Pane Customization form, and open the Task Pane Manager Options. Select the My HTML pane from the tree, and select the My Stock Quote category. Enter a stock symbol in the text box, and click OK. Navigate to your task pane, and you should see the stock information. You will notice there is a link to the Task Pane Options to jump to the Stock Symbol option directly from the pane using a built-in handler (Figure 14).

Figure 14   You can easily call Web services and specify custom options for your pane subsections.

Displaying Dynamic Information

In the next section, you will read data from a file on the Internet. This technique can be an alternative to calling an XML Web service if the content changes less often or the information is easily created by a human instead of a computer. For instance, tool vendors can provide links to online Help and resources, white papers and articles, or their commercial Web site by creating a file on the Internet and having the pane read that file. When the links are updated, the information is updated on all of the developers' task panes. Microsoft uses this technique to display dynamic information on the Start, Solution Samples, and XML Web Services task panes.

For this example, you create an XML file that displays links to a fictitious tool vendor called "Cool Tools." The file is named Coolinfo.xml and contains the following information:

<?xml version='1.0' encoding='windows-1252' standalone='no'?>
<VFPData>
   <content>
      <name>Cool Tools Home Page</name>
         <link>
            <![CDATA[vfps:linkto?url=http://www.massitools.com/default.htm]]>
         </link>
      <desc>Take a tour of all the Cool Tool products!</desc>
   </content>
   <content>
      <name>Cool Tools Reference</name>
         <link>
            <![CDATA[vfps:linkto?url=http://www.massitools.com/help.htm]]>
         </link>
      <desc>Access the Cool Tools Help file.</desc>
   </content>
   <content>
      <name>Cool Tools News</name>
         <link>
            <![CDATA[vfps:linkto?url=http://www.massitools.com/news.htm]]>
         </link>
      <desc>Get the most up-to-date information on Cool Tools.</desc>
   </content>
</VFPData>

There are three content nodes defined in the XML file that contain brief descriptions and URLs to Web pages on the Internet (the URLs in this example do not exist). This file theoretically lives on the Cool Tools commercial Web site. O course, this site does not really exist, so for this example you can place the file on your own Web site or on your local Web server. However, the file does not actually have to be on a Web server. It can be located on a network share, or you can put it on your local hard drive. Keep in mind that this file is not distributed with the task pane; so putting it on your local drive is for testing purposes only.

To set up the dynamic content subsection, click the Add button on the content toolbar and name it "What's New with Cool Tools." Then open the Data tab, and select URL for the Source. In the text box, enter the URL to the file:

http://www.massitools.com/coolinfo.xml

If you placed the file on your local C drive for testing purposes, type the following in the text box:

file://c:/coolinfo.xml

Now you specify the transformation of this data into HTML. Open the Transform Data tab, select XSL as the Type and Static Text as the Source, and enter the following XSL transformation:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="VFPData">
   
   <table border="0" width="100%" cellpadding="2" cellspacing="0" >
      <xsl:apply-templates />
   </table>

</xsl:template>

<xsl:template match="content" name="contents">
   <xsl:variable name="linkvar" select="link"/>
   <tr>
<td>               
      <a href="{$linkvar}"><xsl:value-of select="name"/></a>
      </td>
   </tr>   
   <tr>
<td class="description"> 
      <xsl:text>-    </xsl:text><xsl:value-of select="desc"/> 
   </td>
   </tr>   
</xsl:template>
</xsl:stylesheet>

This transforms the XML into an HTML table that is used on the final transformation of the root content. Now the XML content contained in the Coolinfo.xml file is downloaded from the specified location and cached according to the Task Pane Manager settings. That way if the connection cannot be established later, the cached copy is used. If the URL cannot be reached the first time you open the pane, you can specify default XML data to display on the Default Data tab. Typically, you just copy the contents of the online file into the edit box on this tab. However, you can place any data there as long as it is in the same format as the online file so that the transformation will work correctly.

Now click Apply, and the pane refreshes to display the new "What's New with Cool Tools" section (Figure 15). You can see the XML content displayed on the pane. If you modify the Coolinfo.xml file and click the Refresh button on the Task Pane Manager, the content section updates. This is one way you can easily push dynamic content to your users' desktops.

Figure 15   You can create task pane subsections that display dynamic content from files on the Internet.

Using Custom Handlers and Interacting with the Browser

You now call custom handler code from a hyperlink and manipulate the HTML on the pane from your code using the browser object. You create a link that restarts the Internet Information Server on your local computer. Because this process can take a few moments, status messages display on the pane while the IIS services are shutting down and starting back up. You call the IIS command-line utility iisreset to do this.

First, create a new content subsection called Utilities. On the Data tab, select Static Text as the Source. Enter the following HTML:

<a href="vfps:runbatch?utility=iisreset">Restart IIS</a>
<BR>
<span id=status></span>

Specify a runbatch custom handler and passing it a utility parameter iisreset. This data also contains an empty <SPAN> element that you use to display status messages on the pane. On the Handler Code tab, You then specify the code to run when this link is clicked.

LPARAMETERS cAction, oParameters, oBrowser, oContent
LOCAL cUtility
cUtility = oParameters.GetParam("utility")
DO CASE
CASE cAction == "runbatch"
   oBrowser.document.all.status.innerText = "Restarting IIS, please wait..."
   RUN &cUtility 
   oBrowser.document.all.status.innerText = "IIS has been restarted."
ENDCASE

For this example, we can also specify the handler as iisreset and hard-cod the RUN command. However, this process demonstrates how to retrieve parameters from the parameter object using the GetParam method. Also notice that updates to the pane are made by setting the innerText property of the <SPAN> element by referring to its ID, status. You can use the oBrowser object to access the Document Object Model (DOM) and use Dynamic HTML to manipulate the pane to do whatever you want. Because you are actually running Visual FoxPro code, you also have access to any Visual FoxPro feature you normally would.

This brings up a very important point. When installing task panes from others, make sure you absolutely trust the pane's provider. As you can see, after a task pane is installed, it can run Visual FoxPro code in your security context—so be careful! If you plan on becoming a vendor of task panes over the Internet, you should digitally sign your downloads. Distributing panes within the developer community is no more or less dangerous than exchanging any other code—just be aware of who is giving it to you.

Now click Apply, and the pane refreshes to display our new Utilities section. Click Reset IIS to run the command-line utility iisreset. Notice how the status messages are displayed on the pane (Figure 16).

Figure 16   You can run custom handler code to perform any action from hyperlinks on your task panes.

If your handler code is long or complex you can call a program or class library instead. In this case, your handler calls a DO command (or NEWOBJECT) that specified a file name that you include in the pane cache. For instance, you can enter the following code:

LPARAMETERS cAction, oParameters, oBrowser, oContent
LOCAL cUtility
DO CASE
cUtility = oParameters.GetParam("utility")
CASE cAction == "runbatch"
oUtil = NEWOBJECT("MyUtilities", oContent.CacheDir + "myutilities.prg")
   oUtil.RestartIIS 
ENDCASE

You add the file (in this example, Myutilities.prg) by selecting the View Files option on the Pane Customization form and clicking Add on the file toolbar. This file is then automatically wrapped into the distribution package for you. Take a look at the Solution Samples pane for an example of this technique.

Publishing and Installing Task Panes

The Pane Customization form makes publishing a task pane is very easy. Publishing a pane just means that the pane content and all its files are wrapped up into a distribution package. This package is an XML file that allows for easy distribution and installation of panes into other developers' Task Pane Managers. To publish a pane, select the pane name, and click the Publish button on the pane toolbar. You are prompted as to what exactly you want to publish. You can publish entire panes or just sections you have updated (Figure 17).

Figure 17   You can publish entire panes or just pane sections you have updated.

By default, the Publish all content in pane and the Publish files associated with the pane are selected. This indicates that all the pane sections and all the files in the pane cache are wrapped into a pane installation XML file. If you select Publish selected content only, the data and files related to the content sections you select in the list box are placed in the XML file. If you select Publish files common to all panes, all the files in the root cache are published as well. These files are used by the Task Pane Manager to format errors and present status messages, so it is not necessary for you to select this check box unless you have modified or added to these files. Click OK, and select a name and location for the pane installation XML file. Now only that XML file needs to be distributed for other users to install and update panes into the Task Pane Manager.

To install a new task pane, open the Task Pane Manager Options, and select Task Pane Manager>Customize from the tree view and click the Install Pane button. Navigate to the distribution package (panename.xml) and click OK. The pane appears at the bottom of the list.

Conclusion

Task panes provide numerous possibilities. They help the developer community exchange vital information and open the door for third parties to provide more integrated Visual FoxPro tools. Task panes are set up to render XML/XSLT, Dynamic HTML, display entire Web pages on the Internet, and easily call XML Web services. They can also run rich Visual FoxPro code. Therefore, if you are not familiar with mark-up languages, you can just as easily create panes written in Visual FoxPro.

© Microsoft Corporation. All rights reserved.