Downloads
9175.zip

With Windows 2000 Active Desktop, you can write and use a custom HTML template to display folders and their contents in Windows Explorer. Here’s an example of how you can build a custom HTML template.

Suppose you're customizing a folder that contains XML files with information about the users of a certain application. You maintain the user information in XML files for two reasons. First, XML gives you a powerful object model to parse the data. Second, XML prevents any security problems. Any code you write runs within an HTML page and therefore is subject to the typical security restrictions that the browser applies. The XML object model is safe for use within an HTML page. (If a COM object isn’t marked safe for scripting, you receive security warning messages.)

Figure 1 contains an example of the XML files’ contents. The code in Listing 1 transforms this XML data stream into a Web page. (All the source code for the custom User HTML template is available in the Code Library.)

Listing 1 includes code that lets you switch between the custom view and the standard view. Figure 2 shows the custom view, which hides the folder’s standard content (i.e., the file list). Figure 3 shows the standard view, which shows the folder’s standard content.

The Show Files link in Figure 2 and the Hide Files link in Figure 3 point to a VBScript procedure called Toggle that uses Dynamic HTML (DHTML) to switch between the custom and standard views. Callout A in Listing 1 highlights the Toggle procedure.

An ActiveX control called FileList provides the standard view. The code at callout B in Listing 1 embeds this control in the HTML page but keeps the control invisible. You can change any of the control’s attributes, except the classid.