Welcome Guest!
Create Account | Login
Locator+ Code:

FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Click here to receive your FREE subscription to Visual Studio Magazine

email article
printer friendly

Get Down and Glitzy With Gadgets
Add pizzazz to your users' desktops with Windows Gadgets, lightweight desktop applications that provide useful bits of functionality while also bringing fun back to the development process.
by Dan Fergus

April 23, 2007

Technology Toolbox: C#, XML, Windows Vista

Windows Vista introduces a slick new UI feature Microsoft calls Windows Gadgets. Gadgets are small, lightweight applications that run in a special pane called the Sidebar or directly from the user's desktop. These applications are always-on, providing important services or information to a user.


Windows Vista ships with several gadgets, which range from remote desktop and mail apps, to stock ticker and weather apps. The kinds of apps and services you create with these gadgets have been around for a while, but there is more elegance to the gadgets approach than Windows provided out-of-the-box previously.

The built-in gadgets are nice, but the real power of Windows gadgets lies in the fact that you as a developer can create your own, customized gadgets. The scope and kind of applications you can create with Windows gadgets are limited only by your imagination. Gadgets are useful and versatile, but their biggest strength is much more important than that: Gadgets bring a sense of fun to programming, hearkening back to the days of Visual Studio where you could create new controls and add them to the tool's toolbar.

The heightened fun factor is especially welcome as a developer, where the core technologies we deal with day-in and day-out are often useful, but typically lacking in charm or excitement. Sure, generics are neat from a technological standpoint, as are many of the other advancements in Visual Studio, but I wouldn't call them fun.

Gadgets introduce a modicum of whimsy into an OS that has long been known for its staidness. Gadgets are TSR-like programs run in a pane ("Sidebar" in Microsoft-speak) on the right-hand side of your screen by default (Figure 1).

I'll walk you through how to create your own custom gadgets, as well as how to anchor them to the Sidebar. Specifically, I'll walk you through creating a couple gadgets that illustrate the power and versatility of these applications. First, you'll learn how to create a bare-bones gadget that you can use as a template for other gadgets. Next, you'll learn how to do something more in-depth with a weather gadget that provides the current weather for a given zip code, as well as a two-day forecast. Along the way, I'll point out some of the high and low points of this still-nascent technology, including some workarounds for the caveats that you'll encounter.

Before I walk you through the nitty-gritty, code-level perspective of building and using a gadget, however, it's important to have a solid understanding of what they are and how they work.

Inspect Your Gadgets
In their most basic form, gadgets are nothing more than an HTML script file, and an XML file. This small assortment of files creates a mini-application that can access Web services, RSS feeds, images, the file system, and respond to input by the user through mouse clicks or keyboard input. In their more complex forms, gadgets can use custom DLLs to handle code too complex for scripts and contain numerous complex images. They can also have different states, depending on their specific location on the desktop.

Gadgets typically sit in a pane on the user's desktop called the Sidebar. Users can place the Sidebar on the right or left of the screen, or even specify a specific monitor if they have a dual-monitor setup. Users also have the option to make the Sidebar so it always displays or allow it to be covered by other windows. In this respect, gadgets work similarly to the way the taskbar works. Note that gadgets do not have to be docked on the Sidebar, and users are free to pull them out and move them to any location on the screen (Figure 2).

Back to top

Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTPOnline Home