A while back I was adding a Control Panel class sample
to this site, but wanted to investigate the more advanced Shell Folder type applets.
So this is a little Control Panel applet wrapping a mock-up community
service for the SocWall.com website.
It allows you to go the the Control Panel and browse the most recently submitted wallpaper images from the SocWall.com website. You can select an image and make it your desktop background wallpaper. There would also be (not yet implemented) a page to rate the images and schedule automatic updates of your desktop background.
|The socwall.com website no longer has an RSS feed for consuming wallpapers, so this sample will not display actual images. Still, it is a working implementation of a modern Windows Control Panel widget.|
Shell Folder Control PanelsWindows Vista brings a rekindled interest in the use and promotion of Shell Folders in the Windows Control Panel. Previous designs would concentrate on launching a Property Sheet where the user could make the desired changes. But with Shell Folders and its inline navigation the user will now feel that the Control Panel is one big integrated configuration shell. Microsoft lays out two types of pages to use in a Style Guide document.
- Hub Pages. Hub pages have the task panel visible on the left. The page should either be used to provide further navigation, or if configuration options are placed on the page, the user should never confirm changes and changes must take effect immediately. The Hub page should present simple options for users with explanatory text.
- Spoke Pages. The other page type is a more Wizard-like page where the user needs to acknowledge the changes being made on the page. These pages often contain more complex choices for the user.
This little project has both a Hub page and a Spoke page. The Hub page provides
navigation directions to the Spoke page.
The Control Panel item will appear in the main icon list as usual. It registers itself with several tasks, so you can find it with a word-wheel search for "wallpaper" etc.
The entry page is a Hub page with additional links for actions you can perform, plus an entry in the task pane to schedule periodic updates of your desktop wallpaper.
The Change Wallpaper link takes you to a Spoke task page, which will subscribe to the RSS feed from the SocWall.com website. I'm using the IE7 Feeds Manager API to handle the RSS subscription and updates. After reading the RSS feed, the tool will download the thumbnail images to a list in the background. The list will slowly populate and you can select the images to make them your current desktop wallpaper.
A Warning...Before you rejoice over the fantastic opportunities this rediscovered technology from Microsoft can give you, I must add a grave warning:
Shell Folders are implemented as Shell Namespace Extensions.
Shell Extensions are notorious for Microsoft's poor documentation, shabby support, undocumented or broken features. An anti-trust lawsuit back in 1998 revealed that founder of Microsoft, Bill Gates, was purposely withholding documentation to important parts of the Shell API in order to be able to knock out competitors to the MS Office Suite products (Word Perfect, Lotus Notes; remember those?). Since then the anti-trust threat has been the best way to get shell documentation published. In 2002 Microsoft was forced to release a flurry of APIs previously undocumented. You might think that this would improve the situation but instead Microsoft opted to mock the ruling by providing only paltry documentation, often consisting of one-liners or vague definitions.
The fact that Microsoft itself does not provide a sample for a Control Panel Shell Folder item is likely because they must be implemented as a custom
a corner of the Shell API that Microsoft now publicly states that it has no interest
A Shell Extension in Windows 98 was a matter of implementing a few simple COM interfaces, such as
IPersistFolder. Since then the complexity of the Windows Explorer has
exploded and it has grown into a massive pile of spaghetti code.
Developing a custom Shell Extension in current Windows with backward compatibility
will require you to implement about 30 known interfaces, and then make a stab
at additional undocumented interfaces or official hacks that may get
posted on various newsgroups.
It's a bit sad really, because the Shell does expose some interesting ways to integrate information into the primary navigation tool of Windows.
The Source CodeTo create a Shell Folder Control Panel, you must implement a Shell Namespace Extension. To make Windows Vista see your Shell Extension, you must support a wide range of COM interfaces. You can use this sample as a start project for creating your own folders.
The code is split up in a part that handles the COM interfaces of the Shell, and then a couple of dialogs that provides the user-interface.
I will not go into details with the COM interfaces. The ATL library is used to ease the implementation process. Windows Explorer on Vista will not recognize all the features of a NSE unless you provide at least a scanty implementation of many of the interfaces. The shell doesn't appear to use much of them and apparently is happy with them being written as empty stubs. How little implementation you can get by with is not certain. Future versions of Windows may assume that you implemented everything and break - but because of the lack of documentation this isn't really an option.
Creating the pages' user-interface also have a few problems.
You can find some nice suggestions on how to present your information in a Shell Folder, but Microsoft doesn't provide you with an actual code template. The native applets in Windows are using the now mythical DirectUser library, which is an internally developed (partially windowless) library by Microsoft. It is not available to the public, nor does it provide you with a default implementation of the standard visual areas from the Design Guide, such as the Task pane. Fortunately the Vista Control Panel uses a separate Visual Theme style (available with the UxTheme API) which defines the colours and fonts of most of the decorations. This means that we must ensure that all labels, buttons and links are drawn with a distinct theme class. To do this we must subclass most of the controls on the dialog.
This sample provides a standard implementation of a Hub page dialog, and a
Spoke page dialog. In addition, a special generic control subclass is able
to handle labels, images and buttons so that their rendering is compliant
with the correct visual style. With these tools you can begin to create
Shell Folders that adhere to the Design Guide.
To draw controls with the control panel's visual style, my CThemedLabelCtrl label control will override the
WM_PAINT message and draw
calls with the new
The control can be taught to work as an image (no background) and a hyperlink as well.
Other visuals, such as the large Task pane area, are drawn by directly overloading the
paint handler of the dialog.
By using the layout capabilities of the DirectUser library, Microsoft's own
applets can achieve almost HTML-like flow layout of controls when resizing
The GUI code presented here depends on the WTL library
which doesn't have the same advanced layout algorithms, but still rewards
you with nice resizing of controls with the
As goes for the visual look in the pages, I assume that they will change over time as new versions of Windows are released. Because there is no formal template you embed your dialogs in, a partial rewrite of your visuals may be needed for the next version of Windows. However the design document linked at the top of this page does call Property Sheet-type Control Panels items for legacy, so perhaps we can expect the general appearance to last for a while.
To make your tasks searchable on the main page, you'll need to provide a
task XML definition file, just like the one for the old applet type.
For this sample, the task xml file is registered from the same folder location
as the DLL during installation, and while the one in my old applet sample was automatically
generated, this one must be edited manually.
You'll notice that some things doesn't seem to work right in the Control Panel. For instance, once you browse into the Control Panel item, the search field no longer works. Again, this is because Microsoft has refused to document all the interfaces used by the shell. Even though the Search capability of Windows Vista was the number one hyped feature, apparently the Microsoft Shell Team doesn't feel that you should also be able to offer users the same full User Experience.
Also, this particular Control Panel item would fit conveniently inside the Personalization applet group, but unfortunately the Personalization applet doesn't appear to be extensible.
Source Code DependenciesWindows Vista
Microsoft Visual Studio.NET 2008
Microsoft ATL Library
Microsoft WTL 7.0 Library
- Register the DLL file with the REGSVR32 utility.
See AlsoAn old-school Control Panel applet
A Shell Extension on the desktop
|Binary Files (364 Kb)|
Source Code (145 Kb)