Jonathan 的个人资料Jon's Vista Gadgets Blog日志列表 工具 帮助

日志


2月25日

Gadget basics

If you're new to Gadgets, it can be a little confusing. So here's the basics to creating one:
1. Create a folder for your Gadget in "C:\Users\<username>\AppData\Local\Microsoft\Windows Sidebar\Gadgets". This can be called whatever you like, but it must end with ".gadget" otherwise your Gadget won't appear in the Sidebar Gallery.
eg. "myTestGadget.gadget"
2. Within your newly created folder create a gadget.xml file. This contains information such as the name, icon and description of your Gadget, I've highlighted in Blue the only sections you need be concerned with at the moment.
<?xml version="1.0" encoding="utf-8" ?>
<gadget>
<name>My test Gadget</name>
<author name="Jonathan Abbott">
<logo src="images\icon.png" />
</author>
<copyright>25th February 2007</copyright>
<description>A test Gadget, which does very little.</description>
<icons>
<icon width="64" height="64" src="images\icon.png" />
</icons>
<version>1.0.0.0</version>
<hosts>
<host name="sidebar">
<base type="html" apiVersion="1.0.0" src="gadget.html" />
<permissions>full</permissions>
<platform minPlatformVersion ="0.3" />
</host>
</hosts>
</gadget>
3. Create a gadget.html file. This contains the main Gadget HTML page
<html>
<body style="width: 120px; height:90px;">
Hello world
</body>
<html>

If you now go to the Gadget Gallery, you should see your Gadget. If you add it, you should get a white box with "Hello world" in it. Simple as that.

From here on it gets more complicated. In future articles I'll go into detail on the gadget.xml file, settings pages and flyouts. Not to mention how to overlay transparent text/images and various bugs you're going to come across along the way.