The Windows Vista and Windows Server 2008 Developer Story: Developing for Windows Shell

 

Microsoft Corporation

March 2007

Summary: The Windows Vista and Windows Server 2008 Developer Story includes content for developers and other technology experts and managers who are interested in an in-depth exploration of some of the new and extended features in Windows Vista. It is released to the Windows Vista Developer Center in the form of brief articles, published approximately once every two weeks. Many of those articles are only a summary of the Microsoft Windows Help file, which can be downloaded here. To locate this article in the downloaded Help file, expand Fundamentals, expand Windows Shell (Windows Vista), and then expand and click Developing for Windows Shell. (8 printed pages)

Note   To provide feedback about the articles, please send e-mail to Vistadev@microsoft.com.

Contents

Introduction
Developing with Common File Dialog Boxes
Developing for Desktop Window Manager (DWM)
Developing with Windows Explorer
Developing with Internet Explorer
New Shell Interfaces for Windows Vista
New Shell Functions for Windows Vista
Other Useful Links

Introduction

The Windows Shell is the container in which the entire Windows Vista user interface (UI) is presented, including the taskbar, the Desktop, Windows Explorer, and many of the dialog boxes and interface controls.

In Microsoft Windows version 3.0, the original Shell was implemented as a native Win16 DLL with a corresponding API. It featured multiple, overlapping windows and the Program Manager for browsing and managing the file system. Microsoft Windows 95 featured many UI improvements, a new Windows Explorer, and a new COM-based platform and corresponding APIs. Microsoft Internet Explorer version 3 added Internet shortcuts and browser extensions. Each subsequent version of Windows and Internet Explorer resulted in additional capabilities and a corresponding expansion of the Win32 and COM APIs. The runtime for the Shell is distributed over a number of dynamic-link libraries (DLLs). For more information, see "Road Map for the Windows Shell" in the Windows Software Development Kit (SDK).

The Shell features in Windows Vista that address data and metadata include the Synchronization Manager, Live Icons, Rich Preview, and property handlers. Developing for Control Panel is discussed in the Windows Vista Management section of "Fundamentals" in the Windows SDK. For more information, see "Developing for Control Panel" in the MSDN Library.

This article provides information about changes in the following areas:

  • Developing with common file dialog boxes—Describes how to program common dialog boxes: the generic file, file open, and file save. These dialog boxes are new in Windows Vista.
  • Developing for Desktop Window Manager (DWM)—Describes the new engine for managing the visual layout and display of windows on the desktop, and introduces the new set of Shell APIs.
  • Developing with Windows Explorer—Describes the architecture of the new Windows Vista Explorer and how developers can best use its components. Developing with Internet Explorer (IE) introduces the IE platform, introduces ways in which the developer can leverage the platform, and lists the primary changes in IE 7.
  • Developing with Internet Explorer—Describes the major changes in the UI and functionality of IE 7, and describes how software developers can interact with and extend IE.
  • New Shell interfaces—By category, lists the new Shell interfaces for Windows Vista.
  • New Shell functions—Supplies a grouped list of new Shell functions in Windows Vista.

Developing with Common File Dialog Boxes

Windows Vista supplies an updated version of the common file dialog box to meet the needs of the majority of developers. Not only is it powerful, but it also is designed to support customization and extensibility. The Windows Vista Shell provides access to these new file dialog boxes through IFileDialog and related interfaces. The .NET Framework 3.0 applications for Windows Vista can access this functionality through interoperability support in the Windows SDK. For more information, see "Interoperability and Migration" in the MSDN Library.

Using a Common File Dialog Object

Applications that must create an instance of the common file dialog box must obtain one of the following interfaces:

  • IFileDialog—The most generic interface, and the parent of the next two.
  • IFileOpenDialog—Extends IFileDialog to allow applications to control aspects that are particular to open operations, such as selecting multiple items.
  • IFileSaveDialog—Handles Save As operations and works with metadata.

All file dialog boxes are modal. Methods in these classes enable developers to get and set UI elements of the dialog box (such as SetTitle, SetDefaultFolder, SetFileTypes, and GetCurrentSelection) that are typical when using dialog boxes. Many of the standardized behaviors of the dialog box can be controlled through the GetOptions and SetOptions methods by using a set of bit flags. These options can be set only before a dialog box is displayed; otherwise, the SetOptions method returns an error. The final user selection can be retrieved with the GetResult method or by using IFileOpenDialog when the FOS_ALLOWMULTISELECT option is enabled.

Working with File Dialog Box Events

Although instantiating a file dialog object provides the primary UI and functionality of the corresponding common file dialog box, in some clients the practical use of these dialogs requires developers to access events that are generated by dialog box operations or the individual controls of the dialog box.

The IFileDialogEvents interface provides methods that signal user actions and methods that allow notification of events within a common file dialog box. For more information about working with file dialog box events, see the downloadable Help file, which can be downloaded here. To locate this article in the downloaded Help file, expand Fundamentals, expand Windows Shell (Windows Vista), and then expand and click Developing for Windows Shell.

Customizing a Common File Dialog Box

In addition to the UI and behavioral customizations that can be made through the primary dialog box interface and the event interfaces, the IFileDialogCustomize interface that is provided enables developers to add additional common controls to the dialog box either above or below the set of standard controls for that dialog box. These controls include PushButton, ComboBox, EditBox, CheckBox, and RadioButtonList. For more information about customizing a common file dialog box, see the downloadable Help file, which can be downloaded here. To locate this article in the downloaded Help file, expand Fundamentals, expand Windows Shell (Windows Vista), and then expand and click Developing for Windows Shell.

Developing for Desktop Window Manager (DWM)

Desktop Window Manager (DWM) is the new component in Windows Vista that manages the visual layout and display of the Windows Vista Desktop and orchestrates the display of application windows. In previous versions of Windows, applications draw directly to the display device. DWM uses desktop composition to draw a surface—such as an application's window—to an off-screen buffer, before it is composited with all other surfaces to render the desktop. For more information about developing for DWM, see the downloadable Help file, which can be downloaded here. To locate this article in the downloaded Help file, expand Fundamentals, expand Windows Shell (Windows Vista), and then expand and click Developing for Windows Shell.

Developing with Windows Explorer

Windows Explorer in Windows Vista is a powerful resource-browsing and management application. Windows Explorer can be accessed as an integrated whole through Explorer.exe or the IExplorerBrowser Shell interface.

Windows Explorer (Explorer.exe) can be spawned as a separate process by using the ShellExecuteEx or similar function. The command-line options are documented on the Microsoft Help and Support site in the article "Windows Explorer Command-Line Options."

Open Explorer windows can be discovered and programmed by using IShellWindows/CLSID_ShellWindows, and new instances of Windows Explorer can be created by using IWebBrowser2/CLSID_ShellBrowserWindow.

A C++ code example that demonstrates how the Windows Explorer automation model can be used to create and discover Explorer windows that are running can be found in the downloadable Help file, which can be downloaded here. To locate this article in the downloaded Help file, expand Fundamentals, expand Windows Shell (Windows Vista), and then expand and click Developing for Windows Shell.

The Windows Explorer client area can be hosted by using the IExplorerBrowser Shell interface. The Windows Explorer client and the namespace tree controls are standard components of Windows Vista, and these interfaces are public. Therefore, developers can reuse the interfaces as building components. One common use of these controls is to create customized explorers that are appropriate to the problem domain.

The controls in Windows Explorer are classified into the following functional categories: Navigation controls, Command controls, Property and preview controls, Filtering and view controls, and Listview control**.**

Navigation controls assist users in determining context and navigating the associated logical domain space, which is called the pagespace. For example, the pagespace for Windows Explorer is the Shell namespace. Pagespaces are composed of zero or more pages.

The following table lists and describes the Navigation controls that are available in Windows Explorer, in the Windows Vista operating system.

Navigation control Description
Address Bar (Breadcrumb control) Displays the address of the current page in the pagespace. Breadcrumb buttons can be clicked to navigate up to any ancestor in pagespace. Users can still type URLs and paths to navigate.
Folder Tree Provides a new version of a tree control, optimized for large pagespaces.
Travel Enables relative navigation through Web-style buttons, such as Back and Forward.
Title Displays the current Explorer name and context.
Pagespace Displays the current branch of the pagespace. Pages can be ordered by different criteria. Users can click a page to navigate to it.

Command Controls

Command controls advertise the features and functionality of the Explorer to users, and they perform either general actions or actions that are specific to one selected item or items.

Command control Description
Toolbar Displays buttons for commonly used commands (a new version of a command toolbar). Customization options include drop-down buttons, split buttons, optional descriptive text, and an overflow area.
Hero Appears as an optional, single-custom control in the center of the Toolbar. Represents the primary command for the current context.
Menu Bar Presents commands through menus (legacy control in Windows Explorer).
Context Menu Lists a contextually relevant subset of available commands that are displayed as a result of clicking with the right mouse button.

Property and Preview Controls

Property and preview controls are used to preview items, as well as to view and edit item properties.

Control Description
Preview Displays a preview of the selected item, such as a thumbnail or a Live Icon.
Properties Displays properties of the selected item. For multiple selections, it displays summary of properties for the selected group of items. For null selection, it displays a summary of properties for the current page (contents of the listview).

Filtering and View Controls

Filtering and view controls are used to manipulate the set of items in the listview and to change the presentation of items in the listview.

Control Description
Filter Filters or arranges items in listview, based on properties listed as columns. Clicking on a column sorts by that property.
Wordwheel Dynamically and incrementally filters the displayed items in listview, based on input-text string.
View Enables the user to change the view mode of the Listview control. Also, a slider can be used to determine icon size.

Listview Control

The Listview control is used to view a set of items in one of four view modes: Details, Tiles, Icons, or Panorama. The Listview control also enables the user to interact with one or more items through selection and activation.

Caution   Although some of these controls have names and/or functionality that are similar to standard Windows Presentation Foundation (WPF) controls that are found in the System.Windows.Controls namespace, they are distinct classes.

These separate controls are wired together largely through events that are generated either by user interaction or by the controls themselves. Three primary event categories include the following:

Event category Example
Navigation Going from one page to another
Selection Changing the current selection in the listview
View Change Changing the presentation order or view mode in the listview

With such a rich and functional set of controls upon which to draw, developers can focus on describing their pagespace and implementing behavior that is associated with their content.

At the time of this writing, the Windows SDK does not yet contain documentation on these Explorer controls; however, the ExplorerBrowserAPI example is provided in the Samples directory.

Developing with Internet Explorer

In addition to being the premiere Web browser, Microsoft Internet Explorer (IE) is a complex and powerful platform for independent software development. Developers can interact with and extend IE through a number of methods and technologies, including the following:

  • Spawned instances
  • Automated instances
  • Asynchronous pluggable protocols
  • Browser extensions
  • Browser Helper Objects (BHOs)
  • Component download
  • Remote application execution
  • Component reuse

Spawned Instances

Many applications spawn an instance of IE to view a known resource—for example, browse to a Web page or display a local HTML file. This can be accomplished by using the ShellExecute function to execute IExplore.exe directly, or by indirectly opening a data file that is associated with IE on the current machine—for example, an .html file. This latter option assumes that IE is the default browser. The same can be accomplished in a managed application by using System.Diagnostics.Process.Start.

Automated Instances

A finer control over an instance of IE is made available through the InternetExplorer COM automation object.

Asynchronous Pluggable Protocols

A COM-based API enables the creation of customized, pluggable protocol handlers, MIME filters, and namespace handlers. In this way, IE can be extended to understand new communication protocols and document formats.

Browser Extensions

Browser extensions enable developers to modify the user interface of IE by adding custom Explorer bars, new context-menu entries, Tool menu commands, and associated toolbar buttons.

Browser Helper Objects (BHOs)

Browser Helper Objects (BHOs) enable the extension of IE with custom, in-process COM components. BHOs load every time that IE starts, and they can perform any action on the available IE windows and modules—including customizing the browser UI, handling events, hooking messages, and interpreting custom data formats.

Component Download

IE can be used to distribute components—such as Microsoft ActiveX controls (.ocx), dynamic-link library files (.dll), executables, and Java class files or applets—to client machines for on-demand usage or permanent installation scenarios. IE supports signed cabinet files (.cab) to package distribution sets, information files (.inf) to provide installation instructions, and an Open Software Description (OSD) file to describe software components and their relationships.

Remote Application Execution

Client-server technologies—such as Microsoft ASP.NET or Terminal Services Remote Desktop Web Connection ActiveX control—enable IE to host applications that run (at least partially) on a server.

Component Reuse

The modular architecture of IE provides developers with a number of powerful, reusable ActiveX controls that can be used in independent applications. The most common of these are the WebBrowser control (Shdocvw.dll), which provides a mini-browser with navigation and history, and Mshtml.dll, which is the core engine that handles HTML display and parsing.

Many more features and associated services and tools are associated with IE, such as the MSHTML Editor, Microsoft XML Core Services (MSXML) parser, and the Hyperlink Architecture. For more information, see "Internet Explorer Development" in the MSDN Library and visit the Internet Explorer Developer Center.

What Is New in Internet Explorer 7?

Many major changes have been made throughout the UI and functionality of IE 7. The changes appear especially in the areas of security and updated protocol, and standards support.

The following changes were made with software developers in mind:

  • New Web Feed support—IE 7 prominently supports RSS and ATOM feeds in its interface and through its integration with the Microsoft Web Feeds API. For more information, see "RSS in Windows Vista" in the MSDN Library.
  • Microsoft Phishing Filter—IE 7 includes functionality to protect users against phishing attacks from hostile sites. A complete Phishing Filter, including the ability for system administrators to set group policy for the entire network, is available in IE 7 for all platforms. Developers of well-behaved Web sites benefit greatly from the Phishing Filter, because users will come to trust in the additional control that they have over their environment.
  • Tabbed browser—This UI improvement for users also appears in changes to IE's Document Object Model (DOM) and associated APIs. For more information, see "Tabbed Browsing for Developers" in the MSDN Library.
  • Better support for existing standards—Support for Internationalized Domain Name (IDN), HTML 4.0.1, cascading style sheets, and portable network graphics (PNG) have been improved.
  • Protected Mode—In Windows Vista, Protected Mode reduces the severity of threats to both IE and extensions that run in IE by eliminating the ability to install malicious code silently through software vulnerabilities. IE 7 uses the Windows Vista Integrity mechanism and User Interface Privilege Isolation (UIPI) to block interaction from IE to system resources and applications with higher integrity. Although Windows Vista and IE contain features to support earlier versions of applications, all new and existing applications should be thoroughly tested on Windows Vista with IE 7.
  • Native XMLHTTP support—IE 7 implements a version of XMLHTTP that is a native, scriptable object, instead of an object. Users now can have ActiveX controls switched off yet still maintain a client-side connection with a server, so that dynamic transactions that use XML data can continue to run in the background. This allows new, dynamically retrieved data to be inserted into a current, otherwise static, HTML page.
  • Windowless Select control—Although this change enables z-order and zoom to work correctly, existing applications that rely on the HWND of this control must be rewritten to use DOM.

For more information, see "What's New in Internet Explorer 7" in the MSDN Library.

New Shell Interfaces for Windows Vista

An extensive set of COM interfaces have been added to the Shell in Windows Vista, and these greatly extend its built-in capabilities. For more information about the new Shell interfaces for Windows Vista, see the downloadable Help file, which can be downloaded here. To locate this article in the downloaded Help file, expand Fundamentals, expand Windows Shell (Windows Vista), and then expand and click Developing for Windows Shell.

New Shell Functions for Windows Vista

An extensive set of functions for Win32, the unmanaged programming model for the Microsoft Windows operating system, have been added to the Shell API in Windows Vista. For more information about the new Shell functions for Windows Vista, see the downloadable Help file, which can be downloaded here. To locate this article in the downloaded Help file, expand Fundamentals, expand Windows Shell (Windows Vista), and then expand and click Developing for Windows Shell.

The Windows Vista Developer Story: Windows Shell (Windows Vista)