Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
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

Get Down and Glitzy With Gadgets (Continued)

Microsoft supports three different types of gadgets: the aforementioned Sidebar gadgets, as well as Live and SideShow gadgets. Gadgets for Windows Live present the gadget's data to the user through a Web browser (Figure 3), while SideShow gadgets display data on a hardware device using a SideShow device driver. In this article, I'll restrict myself to discussing only Sidebar gadgets that are supported in Vista.

It's easy to build a basic gadget. Every gadget consists of a minimum of two files: a gadget.xml file and an HTML file. For the Sidebar to see your gadget, you must place these files in the correct folder. For example, the full path to store the files on my system is this:

C:\Users\dfergus\AppData\Local\Microsoft\Windows 
   Sidebar\Gadgets

You can shorten this by using a system variable. The shorter form looks like this:

%LOCALAPPDATA%\Microsoft\Windows 
   Sidebar\Gadgets
ADVERTISEMENT

You create a separate folder in this location for each of the gadgets that you develop, and these folders must adhere to a specific naming standard. The folder is your gadget name with .gadget appended to the name. For example, the initial gadget I'll show you how to create is called "Simple"; it goes in a folder called "simple.gadget."

You begin building a gadget by creating the first of two required files (Listing 1). Note that this manifest file is always called gadget.xml, no matter what your gadget is called. The information in this file is displayed in the details section of the gadgets that are available on your computer (Figure 4). Note that you can add the logo and icon elements to customize your gadget's look in the browser. This file links to the other required gadget file through the base element and the src attribute.

The second required file, simple.html, is also easy to create:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <title>Simple Gadget</title>
   <style type="text/css">
      body{
         width:130;
         height:50; 
      }      
      span{
         font-family: Tahoma;
         font-size: 12pt;
      }
   </style>
</head>
<body>
   span id=<"HelloText">Hi Mom!</span>
</body>
</html>

You can't get more basic than this. The file sets the gadget's size on the Sidebar, specifies a font for the text, and then sets a span for the text.

Build a Weather Gadget
So far, so good. You've created an elementary gadget. It doesn't do anything more than display static text, but any gadget you create will trace these same steps. You can do almost anything within the script code of a gadget. For example, you can access the Internet, pull RSS feeds, or access system resources and applications. Once you get the basics down, you can create more elegant and substantial gadgets without having to perform a lot of extra work.

Previous 1 2 3 4 5 6 Next
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