<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ioan Lazarciuc&#039;s Weblog &#187; Vista</title>
	<atom:link href="http://www.lazarciuc.ro/ioan/tag/vista/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lazarciuc.ro/ioan</link>
	<description>I program, therefore I exist.</description>
	<lastBuildDate>Mon, 19 Dec 2011 06:24:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Creating a Windows Vista Sidebar Gadget</title>
		<link>http://www.lazarciuc.ro/ioan/2007/11/01/creating-a-windows-vista-sidebar-gadget/</link>
		<comments>http://www.lazarciuc.ro/ioan/2007/11/01/creating-a-windows-vista-sidebar-gadget/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 23:39:20 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Beginnings]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Gadget]]></category>
		<category><![CDATA[Sidebar]]></category>
		<category><![CDATA[Vista]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2007/11/01/creating-a-windows-vista-sidebar-gadget/</guid>
		<description><![CDATA[I think this post should begin with a few sayings: "Never say never", "When hell freezes over", "Once in a blue moon", "I would rather shoot myself", "Over my dead body", but the best suited one for this post comes from Ciprian Jichici, the Microsoft Regional Director from Romania: "In this line of business, there's [...]]]></description>
			<content:encoded><![CDATA[<p>I think this post should begin with a few sayings: "Never say never", "When hell freezes over", "Once in a blue moon", "I would rather shoot myself", "Over my dead body", but the best suited one for this post comes from <a TITLE="Ciprian Jichici's Website" HREF="http://www.ciprianjichici.ro/" TARGET="_blank">Ciprian Jichici</a>, the <a TITLE="Microsoft Regional Director Website" HREF="http://microsoftregionaldirectors.com/" TARGET="_blank">Microsoft Regional Director</a> from Romania: "In this line of business, there's no room for talibanisms".</p>
<p>I will be talking about developing Sidebar gadgets. These Sidebar gadgets are small applications that offer useful information, do frequent tasks more easily, or just offer a good laugh for the Windows Vista user. Until recently, I've been trying very hard to stay away from technologies like JavaScipt and PHP because it is my personal opinion that they fall miles away from a proper programming language (C#, VB.NET, C++). I won't go into the details of why I dislike these languages.</p>
<p>Microsoft launched a <a TITLE="Gadget Competition Website for Romania" HREF="http://www.gadgetcompetition.com/" TARGET="_blank">competition</a> for Sidebar gadget developers with some very nice prizes. The competition takes place in several countries, including Romania. So, I decided to participate. The only problem is that the only fully supported programming model for developing Sidebar gadgets is HTML application + JavaScript.</p>
<p><span id="more-14"></span></p>
<p>I've spent several weeks trying to find another way to develop gadgets. I found out that by using <a TITLE="A site for information aobut XBAP" HREF="http://www.xbap.org/" TARGET="_blank">XBAP</a>(XAML Browser Application), one can obtain a gadget that can be programmed using <a TITLE="MSDN WPF Site" HREF="http://msdn2.microsoft.com/en-us/library/ms754130.aspx" TARGET="_blank">WPF</a> (Windows Presentation Foundation) - more information on that <a TITLE="How to Create a Sidebar Gadget using XBAP" HREF="http://blogs.msdn.com/jbeavers/archive/2007/05/30/creating-the-simple-xbap-sidebar-gadget.aspx" TARGET="_blank">here</a>. There are real drawbacks to this approach: no flyouts, no access to the gadget settings API, no access to the Gadget API, which are all accessible from JavaScript. Also, <a TITLE="Silverlight Website" HREF="http://www.microsoft.com/silverlight/" TARGET="_blank">Silverlight</a> can be used to create a Sidebar gadget. While this significantly improves access to the JavaScipt API's, there are still drawbacks. More on creating gadgets using Silverlight <a HREF="http://blogs.msdn.com/charles_sterling/archive/2007/05/14/writing-a-windows-sidebar-gadget-in-silverlight-dead-simple.aspx" TARGET="_blank">here</a> and <a HREF="http://blog.benhall.me.uk/2007/05/vista-sidebar-gadget-using-silverlight.html" TARGET="_blank">here</a>. The decision was tough to make, but unavoidable: JavaScript won, due to the fact that my gadget needed settings, flyouts and a standard installation experience (no dependencies on Silverlight).</p>
<p>Now the phrase "there's no room for talibanisms" makes sense: you never know when you will be forced to do things you don't particularly enjoy (such as JavaScript). All these being said, I shall move on the the task at hand. The best place to start when learning to develop gadgets is the <a TITLE="Basic Tutorial for Sidebar Gadget Development" HREF="http://microsoftgadgets.com/Sidebar/DevelopmentOverview.aspx" TARGET="_blank">Overview Site</a> from Microsoft. The ABCs of developing gadgets are covered there. Tim Heuer has made a project template for Visual Studio in order to help people getting started in gadget development. The template is available <a TITLE="Visual Studio Project Template for Gadget Development" HREF="http://www.timheuer.com/blog/archive/2007/03/11/14010.aspx" TARGET="_blank">here</a>.</p>
<p>From here, the purpose of the new gadget has to be formulated. It can be as simple as "Hello World", or as complicated as interfacing with your Windows Media Player. The first step is to go over to the <a TITLE="Live Gallery for Sidebar Gadgets" HREF="http://vista.gallery.microsoft.com/vista/SideBar.aspx" TARGET="_blank">Live Gallery</a> dedicated to Vista Sidebar Gadgets and have a look at what's out there. I settled on creating a gadget that would display the postal code (ZIP) for a given address from Romania. I chose this because I had been searching too many times for postal codes on websites. The gadget is a very welcomed shortcut. The data is to be obtained from one of the many sites that offer Romanian ZIP search. The only requirement is to be able to pass the search string as a query string directly in the URL to keep things simple. I settled on <a HREF="http://coduri-postale.ro">http://coduri-postale.ro</a>.</p>
<p>The next step is to get up to date with some basic <a TITLE="JavaScript Tutorial" HREF="http://www.w3schools.com/js/default.asp" TARGET="_blank">JavaScript</a>: <a TITLE="HTML DOM" HREF="http://www.w3schools.com/htmldom/dom_reference.asp" TARGET="_blank">HTML DOM</a>, <a TITLE="CSS Refference" HREF="http://www.w3schools.com/css/css_intro.asp" TARGET="_blank">CSS</a>, <a TITLE="Regular Expressions" HREF="http://www.devarticles.com/c/a/JavaScript/Regular-expressions-in-JavaScript/" TARGET="_blank">Regular Expressions</a>, the <a TITLE="Sidebar Gadget API Refference" HREF="http://msdn2.microsoft.com/en-us/library/aa965853.aspx" TARGET="_blank">Sidebar Gadget API</a>. Now it's time to take a look at the structure generated by the Visual Studio template.</p>
<p>A Sidebar gadget has at least 2 files: a HTML file which defines the look of the gadget and an XML file which defines information about the gadget such as the name, version, author, description. However, usually, a gadget contains more files such as: HTML files for various flyouts, JS files for the JavaScript functions that are called and CSS files for defining styles in a civilized manner.</p>
<p>The main file of the gadget is called by default, gadget.html. It contains 2 div tags, one with the ID "docked" and one "undocked". As you can imagine, one holds the contents while docked, the other while undocked. In JavaScript, the events System.Gadget.onDock and System.Gadget.onUndock are defined in order to handle the switch between modes. The event handlers are set in the Init function found in the utils.js file.</p>
<p STYLE="border-right-color: #808080; border-right-width: 1px; border-right-style: solid; padding-right: 4px; border-top-color: #808080; border-top-width: 1px; border-top-style: solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; overflow: auto; border-left-color: #808080; border-left-width: 1px; border-left-style: solid; width: 97.50%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom-color: #808080; border-bottom-width: 1px; border-bottom-style: solid">&nbsp;</p>
<p STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">&nbsp;</p>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"><span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">body</span> <span STYLE="color: #ff0000">onload</span><span STYLE="color: #0000ff">="init();"</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">div</span> <span STYLE="color: #ff0000">id</span><span STYLE="color: #0000ff">="docked"</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> Gadget Docked</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">br</span><span STYLE="color: #0000ff">/&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">input</span> <span STYLE="color: #ff0000">type</span><span STYLE="color: #0000ff">="button"</span> <span STYLE="color: #ff0000">value</span><span STYLE="color: #0000ff">="Flyout"</span> <span STYLE="color: #ff0000">onclick</span><span STYLE="color: #0000ff">="flyout();"</span> <span STYLE="color: #0000ff">/&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">div</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">div</span> <span STYLE="color: #ff0000">id</span><span STYLE="color: #0000ff">="undocked"</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> Gadget Undocked</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">div</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"><span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">body</span><span STYLE="color: #0000ff">&gt;</span></pre>
<p>The gadget.xml file contains the name, author, description of the gadget, but also it specifies the main source file for the gadget in the &lt;base&gt; node from &lt;hosts&gt;. The file also contains the path to an icon which represents the gadget and an image to display (defaultImage in &lt;hosts&gt;) while dragging the gadget (only when dragging it from the "Add Gadgets" window).</p>
<p STYLE="border-right-color: #808080; border-right-width: 1px; border-right-style: solid; padding-right: 4px; border-top-color: #808080; border-top-width: 1px; border-top-style: solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; overflow: auto; border-left-color: #808080; border-left-width: 1px; border-left-style: solid; width: 97.50%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom-color: #808080; border-bottom-width: 1px; border-bottom-style: solid">&nbsp;</p>
<p STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">&nbsp;</p>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"><span STYLE="color: #0000ff">&lt;?</span><span STYLE="color: #800000">xml</span> <span STYLE="color: #ff0000">version</span><span STYLE="color: #0000ff">="1.0"</span> <span STYLE="color: #ff0000">encoding</span><span STYLE="color: #0000ff">="utf-8"</span> ?<span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"><span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">gadget</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #008000">&lt;!-- The name will appear on the Gadget Tile and settings window --&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">name</span><span STYLE="color: #0000ff">&gt;</span>[ YOUR GADGET NAME ]<span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">name</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">namespace</span><span STYLE="color: #0000ff">&gt;</span>[YOUR CUSTOM NAMESPACE]<span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">namespace</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">version</span><span STYLE="color: #0000ff">&gt;</span>1.0.0.0<span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">version</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">author</span> <span STYLE="color: #ff0000">name</span><span STYLE="color: #0000ff">="[AUTHOR NAME]"</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">info</span> <span STYLE="color: #ff0000">url</span><span STYLE="color: #0000ff">="[URL FOR INFO]"</span> <span STYLE="color: #0000ff">/&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #008000">&lt;!-- The logo file will display on the more details window of the Gadget Tile window --&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">logo</span> <span STYLE="color: #ff0000">src</span><span STYLE="color: #0000ff">="logo.png"</span> <span STYLE="color: #0000ff">/&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">author</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">copyright</span><span STYLE="color: #0000ff">&gt;</span>© [COPYRIGHT INFO]<span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">copyright</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #008000">&lt;!-- The description displays in the Gadget Tile window when the Gadget is selected --&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">description</span><span STYLE="color: #0000ff">&gt;</span>[YOUR DESCRIPTION]<span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">description</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">icons</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">icon</span> <span STYLE="color: #ff0000">height</span><span STYLE="color: #0000ff">="48"</span> <span STYLE="color: #ff0000">width</span><span STYLE="color: #0000ff">="48"</span> <span STYLE="color: #ff0000">src</span><span STYLE="color: #0000ff">="icon.png"</span> <span STYLE="color: #0000ff">/&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">icons</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">hosts</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">host</span> <span STYLE="color: #ff0000">name</span><span STYLE="color: #0000ff">="sidebar"</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">base</span> <span STYLE="color: #ff0000">type</span><span STYLE="color: #0000ff">="HTML"</span> <span STYLE="color: #ff0000">apiVersion</span><span STYLE="color: #0000ff">="1.0.0"</span> <span STYLE="color: #ff0000">src</span><span STYLE="color: #0000ff">="gadget.html"</span> <span STYLE="color: #0000ff">/&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">permissions</span><span STYLE="color: #0000ff">&gt;</span>Full<span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">permissions</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">platform</span> <span STYLE="color: #ff0000">minPlatformVersion</span><span STYLE="color: #0000ff">="1.0"</span> <span STYLE="color: #0000ff">/&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;</span><span STYLE="color: #800000">defaultImage</span> <span STYLE="color: #ff0000">src</span><span STYLE="color: #0000ff">="drag.png"</span> <span STYLE="color: #0000ff">/&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">host</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">hosts</span><span STYLE="color: #0000ff">&gt;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"><span STYLE="color: #0000ff">&lt;/</span><span STYLE="color: #800000">gadget</span><span STYLE="color: #0000ff">&gt;</span></pre>
<p><a HREF="http://11011.net/software/vspaste"></a><a HREF="http://11011.net/software/vspaste"></a></p>
<p>The size of the gadget (or the flyout) can be changed by changing the size of the body of the html, either from CSS, HTML or JavaScript.  If the gadget has two different size when docked or undocked, then one should change the size of the html body using JavaScript in the event handlers for the Dock and Undock events. The utils.js file contains a function ShowOrHide that takes an HTML element and a boolean and hides(or shows) the element, along with any of its children. The function flyout() from utils.js creates a new flyout by specifying the file property of System.Gadget.Flyout, and then setting show to true.</p>
<p>One can specify a settings HTML page by setting the settingsUI property of System.Gadget. The settings page cannot be opened programmatically, only by the user's action (the settings button that the runtime creates for each gadget that supports settings automatically). The event onSettingsClosed is raised whenever the settings page closes, either by pressing ok or cancel. The onSettingsClosing event can be handled in order to save settings. It's handlers have a parameter which has a property closeAction. If this property is event.Action.commit, where event is the parameter passed to the handler, then the ok button was pressed. In order to write settings, one calls the write method and for reading, the read method of System.Gadget.Settings.</p>
<p STYLE="border-right-color: #808080; border-right-width: 1px; border-right-style: solid; padding-right: 4px; border-top-color: #808080; border-top-width: 1px; border-top-style: solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; overflow: auto; border-left-color: #808080; border-left-width: 1px; border-left-style: solid; width: 97.50%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom-color: #808080; border-bottom-width: 1px; border-bottom-style: solid">&nbsp;</p>
<p STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">&nbsp;</p>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">SystemGadget.Settings.write(<span STYLE="color: #006080">"settingname"</span>,settingvalue);</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">System.Gadget.Settings.read(<span STYLE="color: #006080">"settingname"</span>);</pre>
<p>When loading the settings page, it is the responsibility of the page (through JavaScript) to read its settings and update the fields in the settings html in order to reflect the current values of the settings. This is the purpose of the loadSettings function available in the settings.html file from the template.</p>
<p>This covers all the main aspects in the template for Sidebar gadgets. Another very useful thing to master is the XMLHttpRequest object in JavaScript. This is used in order to obtain the contents of another page (any webpage) asynchronously. This object is part of the AJAX web programming paradigm. Unfortunately, like CSS, HTML and JavaScript, each browser has its own way of looking at this object. There are at least 3 methods of constructing the XMLHttpRequest  object, the bad news being that only one will work for a browser. So you have to try each method, catching exceptions along the way, until the object creation does not throw an exception or all the methods are exhausted, in the worst case. The good news is that for Sidebar gadgets, only Internet Explorer has to be taken into account. Sample code for creating the request object can be found below.</p>
<p STYLE="border-right-color: #808080; border-right-width: 1px; border-right-style: solid; padding-right: 4px; border-top-color: #808080; border-top-width: 1px; border-top-style: solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; overflow: auto; border-left-color: #808080; border-left-width: 1px; border-left-style: solid; width: 97.50%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom-color: #808080; border-bottom-width: 1px; border-bottom-style: solid">&nbsp;</p>
<p STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">&nbsp;</p>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"><span STYLE="color: #0000ff">var</span> xmlhttp = <span STYLE="color: #0000ff">false</span>;</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">try</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> {</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> xmlhttp = <span STYLE="color: #0000ff">new</span> ActiveXObject(<span STYLE="color: #006080">"Msxml2.XMLHTTP"</span>);</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> }</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">catch</span> (e)</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> {</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> xmlhttp = <span STYLE="color: #0000ff">new</span> ActiveXObject(<span STYLE="color: #006080">"Microsoft.XMLHTTP"</span>);</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> }</pre>
<p>The simplest usage scenario involves using the GET http verb in order to simply retrieve a page.</p>
<p STYLE="border-right-color: #808080; border-right-width: 1px; border-right-style: solid; padding-right: 4px; border-top-color: #808080; border-top-width: 1px; border-top-style: solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; overflow: auto; border-left-color: #808080; border-left-width: 1px; border-left-style: solid; width: 97.50%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom-color: #808080; border-bottom-width: 1px; border-bottom-style: solid">&nbsp;</p>
<p STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">&nbsp;</p>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"><span STYLE="color: #0000ff">var</span> ret;</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">xmlhttp.open(<span STYLE="color: #006080">"GET"</span>, url, <span STYLE="color: #0000ff">true</span>);</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">xmlhttp.onreadystatechange=<span STYLE="color: #0000ff">function</span>()</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">{</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">if</span> (xmlhttp.readyState==4)</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">if</span> (xmlhttp.status==200)</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> {</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> ret=xmlhttp.responseText;</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #008000">//do something with ret;</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> }</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">else</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> {</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #008000">//anything other than success can </span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #008000">//be treated as an error</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> }</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">}</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">xmlhttp.send(<span STYLE="color: #0000ff">null</span>);</pre>
<p>The open method takes as parameters the HTTP verb (GET, POST, etc.), the URL for the page to fetch and a boolean that when set to true allows JavaScript to launch the request asynchronously, meaning it keeps on processing the code. If set to false, the execution of JavaScript code stops until the data is fetched or an error occurs. The send method sends the request to the specified web server. If working asynchronously, you can define an event handler for the onreadystatechange event defined by the XMLHttpRequest object to monitor progress. The readyState property indicates the state of the object (4 mean request completed, response available). The status property holds the HTTP status of the response, 200 meaning OK. The actual response can be accessed using the responseText property. When fetching an ordinary webpage, this string will contain the actual HTML of the page.</p>
<p>Sometimes it's useful to do a POST request in order to get to a page that cannot be accessed through an URL. For example for filling out a form in order to obtain some search results (that are not accessible through URL query string parameters). Besides changing the GET into POST, you must also specify the form parameters just as you would query string parameters,only without "?" ('par1=val1&amp;par2=val2') and pass the resulted string to the send method of the request object. Also, some HTTP header have to be set: Content-Type to "application/x-www-form-urlencoded" in order to pass the parameters of the form, Content-length to the length of the string of parameters and Connection to "close" in order to specify that the connection is to be closed once the response is obtained.</p>
<p STYLE="border-right-color: #808080; border-right-width: 1px; border-right-style: solid; padding-right: 4px; border-top-color: #808080; border-top-width: 1px; border-top-style: solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; overflow: auto; border-left-color: #808080; border-left-width: 1px; border-left-style: solid; width: 97.50%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom-color: #808080; border-bottom-width: 1px; border-bottom-style: solid">&nbsp;</p>
<p STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">&nbsp;</p>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">xmlhttp.open(<span STYLE="color: #006080">"POST"</span>, url, <span STYLE="color: #0000ff">false</span>);</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">xmlhttp.setRequestHeader(<span STYLE="color: #006080">"Content-type"</span>, <span STYLE="color: #006080">"application/x-www-form-urlencoded"</span>);</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">xmlhttp.setRequestHeader(<span STYLE="color: #006080">"Content-length"</span>, parameters.length);</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">xmlhttp.setRequestHeader(<span STYLE="color: #006080">"Connection"</span>, <span STYLE="color: #006080">"close"</span>);</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"><span STYLE="color: #0000ff">var</span> ret;</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">xmlhttp.onreadystatechange=<span STYLE="color: #0000ff">function</span>()</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">{</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">if</span> (xmlhttp.readyState==4)</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">if</span> (xmlhttp.status==200)</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> {</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> ret=xmlhttp.responseText;</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #008000">//do something with ret</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> }</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #0000ff">else</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> {</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> <span STYLE="color: #008000">// error occurred</span></pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px"> }</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">}</pre>
<pre STYLE="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow: visible; width: 100%; color: #000000; border-top-style: none; line-height: 12pt; padding-top: 0px">xmlhttp.send(parameters);</pre>
<p>This concludes a basic, but comprehensive article on developing Sidebar gadgets. Even though I was not very specific, I hope you will have no problem stating your own gadget after reading this post.</p>
<p>Currently I have developed 2 gadgets: one to display postal codes from Romania and one to search for schedule and route information for urban transportation in a few major cities from Romania. The source code for these gadget can be obtained by installing them, then by getting the contents of the "C:\Users\%YourUser%\AppData\Local\Microsoft\Windows Sidebar\Gadgets\GadgetName" folder. Also, these two gadgets are competing in the Romanian edition of <a TITLE="International Gadget Competition website" HREF="http://www.gadgetcompetition.com" TARGET="_blank">Gadget Competition</a>. You can download and vote for my gadgets by clicking the two screenshots below.</p>
<p><a TITLE="Romanian Postal Codes" HREF="http://www.gadgetcompetition.ro/ro/ro/GadgetDetail.aspx?g=3990b9c3-c0b3-4695-a7ce-215c5391ac0a" TARGET="_blank"><img ID="id" SRC="http://www.lazarciuc.ro/ioan/wp-content/uploads/2007/Gadgets/RPC.JPG" /></a> <a TITLE="Romanian Urban Transportation Guide" HREF="http://www.gadgetcompetition.ro/ro/ro/GadgetDetail.aspx?g=44cf1503-baaf-44c3-998d-640cae10086a" TARGET="_blank"><img ID="id" SRC="http://www.lazarciuc.ro/ioan/wp-content/uploads/2007/Gadgets/RUTG.JPG" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2007/11/01/creating-a-windows-vista-sidebar-gadget/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

