<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Jaime Rodriguez  : Vista Sidebar Gadgets</title><link>http://blogs.msdn.com/jaimer/archive/tags/Vista+Sidebar+Gadgets/default.aspx</link><description>Tags: Vista Sidebar Gadgets</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>writing a .net activex control for your sidebar gadget..</title><link>http://blogs.msdn.com/jaimer/archive/2006/10/02/writing-a-.net-activex-control-for-your-sidebar-gadget_2E002E00_.aspx</link><pubDate>Tue, 03 Oct 2006 13:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:784322</guid><dc:creator>jaimer</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/784322.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=784322</wfw:commentRss><description>&lt;P&gt;HTML is quite easy for people to get started with, pretty broadly known, light weight, rich enough (if you work hard at it or have nice graphics), etc.. so there is a good set of reasons why the sidebar folks chose HTML as the presentation technology&amp;nbsp; [ I am guessign here] &lt;/P&gt;
&lt;P&gt;However, there are some things that are a little harder to do with HTML [at least they are for me] ... for example, charting (pie charts) ...I tried using VML for this, and had issues.. (it was a little unstable on how it rendered, some times it would stop rendering, I could not figure why)...&amp;nbsp; so for these very extreme scenarios, I am thinking ActiveX might be OK...&amp;nbsp;&amp;nbsp; &lt;BR&gt;&lt;BR&gt;Note that by no means I am advocating activex as the best choice for gadgets, imho the activex registration (regsvr32) breaks the easy, per-user, non-impactful deployment model&amp;nbsp; for gadgets...&amp;nbsp; but I am thinking that there are enterprises (say internal, lob gadgets) that can get away with an impactful deployment model (via MSI or SMS) and benefit from the rich visualization of an activex -say for some BI&amp;nbsp; KPIs...&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Here is what I created code to do:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;An Interface so I can 'raise' some events from my activex to my gadget&amp;nbsp; (outward ) &lt;/LI&gt;
&lt;LI&gt;An interface so I can call from my gadget into the Active X...&amp;nbsp; (inwar) &lt;/LI&gt;
&lt;LI&gt;An ActiveX user control, written in C# that shows UI&amp;nbsp; &lt;/LI&gt;
&lt;LI&gt;some lame code to draw a piechart... just to make me feel good ....&amp;nbsp; it does not update, etc.. very much a token ..&amp;nbsp; I will skip on steps below &lt;/LI&gt;
&lt;LI&gt;Wrote the code to call the activex from my gadget and sink to the events.. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;For reference, here are some good articles in creating .NET Activex controls for IE...&amp;nbsp;&amp;nbsp; I used a little bit from all of these.. &lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/02/01/UserCtrl/" mce_href="http://msdn.microsoft.com/msdnmag/issues/02/01/UserCtrl/"&gt;&lt;FONT face=Calibri color=#0000ff size=3&gt;http://msdn.microsoft.com/msdnmag/issues/02/01/UserCtrl/&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.codeproject.com/cs/miscctrl/exposingdotnetcontrols.asp" mce_href="http://www.codeproject.com/cs/miscctrl/exposingdotnetcontrols.asp"&gt;&lt;FONT face=Calibri color=#0000ff size=3&gt;http://www.codeproject.com/cs/miscctrl/exposingdotnetcontrols.asp&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/event_model.asp" mce_href="http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/event_model.asp"&gt;&lt;FONT face=Calibri color=#0000ff size=3&gt;http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/event_model.asp&lt;/FONT&gt;&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.cisco-cert.com/dotnet_general/574541-How-to-fire-Javascript-events-from-a--NET-winforms-user-control-back-to-Javascript-in-IE" mce_href="http://www.cisco-cert.com/dotnet_general/574541-How-to-fire-Javascript-events-from-a--NET-winforms-user-control-back-to-Javascript-in-IE"&gt;&lt;FONT face=Calibri size=3&gt;http://www.cisco-cert.com/dotnet_general/574541-How-to-fire-Javascript-events-from-a--NET-winforms-user-control-back-to-Javascript-in-IE&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;Come on dude, get to it... show us the code!..&amp;nbsp; &lt;BR&gt;OK .. here you go ...&amp;nbsp;&amp;nbsp; All of the code is commented, please go through it in the project... here I am showing only the 4 tasks above.. |f you are to reuse this, you will have to replace all the lines that have a TODO with your own guids or your own names code &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;FONT color=#008000 size=2&gt;
&lt;P&gt;// Outgoing interface, wired via ComSourceInterfaces on my main class&amp;nbsp; -- see step 3 &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//TODO: Replace the Guid with our own &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Guid&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"56726927-833B-4cfb-94D3-D1501DFD30D2"&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;InterfaceType&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ComInterfaceType&lt;/FONT&gt;&lt;FONT size=2&gt;.InterfaceIsIDispatch)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;interface&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;IGadgetControlEvents&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//TODO: The DispIds must be unique and must be here... I first skipped them and was getting a MethodNotImplementedException &lt;/FONT&gt;&lt;FONT size=2&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DispId&lt;/FONT&gt;&lt;FONT size=2&gt;(1)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; RightClickRelay(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; x, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; y);&lt;BR&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DispId&lt;/FONT&gt;&lt;FONT size=2&gt;(2)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; MouseEnterRelay();&lt;BR&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DispId&lt;/FONT&gt;&lt;FONT size=2&gt;(3)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; MouseLeaveRelay();&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;In my class, I had&amp;nbsp;to expose the events ( showing only RightClick here...&amp;nbsp; the rest you can see in the code) &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000 size=2&gt;// Right Mouse Click will be passed to the gadget... I was hoping I could popup the context menu.. &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;protected&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;override&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; OnMouseClick(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;MouseEventArgs&lt;/FONT&gt;&lt;FONT size=2&gt; e)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.OnMouseClick(e);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (e.Button == &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;MouseButtons&lt;/FONT&gt;&lt;FONT size=2&gt;.Right)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// Did any one subscribe ??? &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (RightClickRelay != &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;BR&gt;{ &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;SecurityPermission&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;SecurityPermissionFlag&lt;/FONT&gt;&lt;FONT size=2&gt;.UnmanagedCode).Assert(); &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// fire the event .. &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;RightClickRelay(e.X, e.Y);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;CodeAccessPermission&lt;/FONT&gt;&lt;FONT size=2&gt;.RevertAssert();&lt;BR&gt;}&amp;nbsp; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;} &lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&amp;nbsp;2 -- Exposing an interface for gadget to call my Activex .. &lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// incoming interface -- so I can call from HTML Gadget .... &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// wired simply by my control class implementing it.. &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// note: I had to implement extra interface because I had the eventing interface... if I did not have eventing, I would not have &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// needed to explicitly implement this extra interface.. &lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//TODO: Replace guid... &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Guid&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"341F46AA-0EA0-4b97-A294-E131D8CFF7E6"&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;InterfaceType&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ComInterfaceType&lt;/FONT&gt;&lt;FONT size=2&gt;.InterfaceIsIDispatch)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;interface&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;IGadgetIncoming&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; SetVariableName(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; name, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; value);&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;to wire the interface, simply implement it in my class ...&amp;nbsp; (see step3 ) &lt;/P&gt;
&lt;P&gt;3.-&amp;nbsp; Creating the activex .. it is simply a .NET Class Library with a UserControl and some attributes: &lt;BR&gt;&lt;BR&gt;&lt;FONT size=2&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// TODO: Replace GUID &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Guid&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"A4B9C3C2-8DAC-451a-AEC1-DE3B042FB311"&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// TODO: Replace Prog Id &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ProgId&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"WindowsFormsUserControl.UserControl"&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//Wire up my eventing interface ..(ComSource)... &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ClassInterface&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ClassInterfaceType&lt;/FONT&gt;&lt;FONT size=2&gt;.None), &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ComSourceInterfaces&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;typeof&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;IGadgetControlEvents&lt;/FONT&gt;&lt;FONT size=2&gt;))]&lt;BR&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ComVisible&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;)]&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;partial&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt; : &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;UserControl&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;IGadgetIncoming&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008080&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008080&gt;5.-&amp;nbsp; Using the object from my gadget &lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;!-- using the object tag to call my ActiveX --&amp;gt; &lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;object&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;id&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="sample"&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; &lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;classid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="clsid:A4B9C3C2-8DAC-451a-AEC1-DE3B042FB311"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;height&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="126" &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;width&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="126"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;style&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="background-color:Transparent;"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;onclick&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="alert('clicked');"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;object&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;script&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;!--&amp;nbsp; one of&amp;nbsp;several ways to sync event; another way is using the FOR statement --&amp;gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;function&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; sample::RightClickRelay ( x, y ) &lt;BR&gt;&lt;/FONT&gt;{ &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// ShowContextMenu (); &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; o = document.getElementById(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;'sample'&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;BR&gt;o.SetVariableName ( &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;'test1'&lt;/FONT&gt;&lt;FONT size=2&gt; , &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;'value1'&lt;/FONT&gt;&lt;FONT size=2&gt;) ; }&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;script&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#008080 size=2&gt;---&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008080 size=2&gt;So, the control is pretty trivial... download the sample code, replace the TODOs ( use GuidGen to generate your guids) and you will reuse it ...&amp;nbsp; There were however a couple of note worthy issues I have not figured out .. [will get to these as soon as I have time ] &lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT color=#008080 size=2&gt;I implemetned the right click so that I could fire the context menu of the gadget .. but the event is raised and I handled it in Javascript, but still could not fire the context menu ..&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT color=#008080&gt;I implemented MouseEnter/Mouse Leave because gadgets show the little drag &amp;amp; drop handle when MouseEnter or it gets focus...&amp;nbsp;&amp;nbsp; One way to get around it, was that I put a Table around it... this way, the table detects when MousEnter/leave happens and lets the sidebar know ...&amp;nbsp; This works for the most part, but if you run you mouse very fast into the gadget, some times table does not fire it .. &lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT color=#008080&gt;&lt;FONT size=2&gt;When you put the activex, you lose the easy drag &amp;amp; drop functionality gadget has.. you an only drag &amp;amp; drop from outside the activex.. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;None of these are blockers, in fact some of the MS gadgets themselves (notes) have these issues but I would like to solve them for a different post ...&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;You can &lt;A class="" href="http://jaimerodriguez.members.winisp.net/gadgetactivex.zip" mce_href="http://jaimerodriguez.members.winisp.net/gadgetactivex.zip"&gt;download the code for this project here&lt;/A&gt;...&amp;nbsp;&amp;nbsp; &lt;BR&gt;There are two directories in the download, the sample.gadget and the ActiveX code itself.. &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;For dev/test deployment, the project in Visual Studio is using the &lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;"Register for COM Interop" checkbox in the Build section of the Project properties to do the registration ... &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;if you are not rebuilding it, or installing it in a box where you are not building it,&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;you will have to register it manually from a .NET Command prompt&amp;nbsp; (or a command prompt with regasm in the path)..&amp;nbsp;&amp;nbsp; &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;regasm /register /codebase WindowsFormsuserControl.dll&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;This leaves the whole topic of how to deploy at run-time...&amp;nbsp; are you going to need admin, etc..&amp;nbsp; I will have to get back to these questions in a future (but will try to not make it to far into the future) post.. .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Cheers, &lt;/SPAN&gt;&lt;FONT color=#008080&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=784322" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Vista+Sidebar+Gadgets/default.aspx">Vista Sidebar Gadgets</category></item><item><title>Using Atlas to make webservices calls  from sidebar gadget.. </title><link>http://blogs.msdn.com/jaimer/archive/2006/10/02/Using-Atlas-to-make-webservices-calls--from-sidebar-gadget_2E002E00_-.aspx</link><pubDate>Tue, 03 Oct 2006 01:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:783919</guid><dc:creator>jaimer</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/783919.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=783919</wfw:commentRss><description>&lt;P&gt;Last post we did a REST call using XmlHttp from a sidebar gadget... but let's admit it, we were all doing xmlhttp calls in 2000 and we were 'geeks'... it was not until 2005? that this exact same code became "cool" because it was called AJAX ...&amp;nbsp; So here is the ticket to get you to the cool group -- every one knows I will never make that :( &lt;/P&gt;
&lt;P&gt;Pre-requisites (or stuff you get with the &lt;A class="" href="http://jaimerodriguez.members.winisp.net/atlasgadget.zip" mce_href="http://jaimerodriguez.members.winisp.net/atlasgadget.zip"&gt;sample code located here&lt;/A&gt;) &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create an Atlas website ( might want to check &lt;A href="http://atlas.asp.net/" mce_href="http://atlas.asp.net/"&gt;http://atlas.asp.net&lt;/A&gt;, if you don't know Atlas, you will need an hour there) &lt;/LI&gt;
&lt;LI&gt;Create a Web Service...&amp;nbsp;&amp;nbsp;&amp;nbsp; mine has the very creative name of "WebService.asmx"&amp;nbsp; and it has a function called GetVolume that returns an object .... [arguably a 'complex type'] &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The client code:&amp;nbsp; &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Copy the atlasruntime.js&amp;nbsp; from a machine that has Atlas installed to your gadget's js directory (or any where that you can get to from your gadget)..&amp;nbsp;&lt;BR&gt;&amp;nbsp;By default, my atlas install put the files under \Program files\Microsoft asp.net\atlas\v2.0.50727\atlas\scriptlibrary\debug&lt;BR&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;STRONG&gt;The trick:&amp;nbsp;&lt;/STRONG&gt;Atlas by default uses frames to get around cross-site scripting...&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;That gets messy if you are trying to generate a proxy with out&amp;nbsp;using the Atlas' server side script manager..&amp;nbsp;&amp;nbsp;&amp;nbsp;so instead I forced Atlas to use xmlhttp with out frames.. and when it goes directly it is a breeze..&amp;nbsp; The caveat is that the parameter to forceXmlHttp is hidden some where that I could not [though did not look too hard] get to easily...&amp;nbsp; if you download the sample code for this project, search atlasruntime.js for 'jaimer' to see the change..&amp;nbsp; for those going at it alone,&amp;nbsp; it is line 2317 ... in atlasruntime.js&amp;nbsp; ( Sept CTP ) ...&amp;nbsp;&amp;nbsp; the code around it looks like this:&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;BR&gt;&lt;BR&gt;Sys.Net.WebRequest = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;function&lt;/FONT&gt;&lt;FONT size=2&gt;() {&lt;BR&gt;Sys.Net.WebRequest.initializeBase(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;, [&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;]);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; _url = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;...... //lots of stuff here &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; _delegateRequest = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//jaimer Changed this line... from &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// var _forceXmlHttp = false; /* to */ &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; _forceXmlHttp= &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true; &lt;/FONT&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;FONT size=2&gt;Create a proxy to your web service from your gadget code..&lt;BR&gt;[So I added a new Javascript file, called AtlasServiceProxy.js and I put the same stuff that atlas gets by making the call to WebService.asmx/js [this is what they use to get the proxy] ...&amp;nbsp; If you have an aspx website, with a webservice, you can just navigate to it using IE, and add the /js after the webservice URL ... (e.g. &lt;A href="http://jaimersvr/AtlasWs/Webservice.asmx/js" mce_href="http://jaimersvr/AtlasWs/Webservice.asmx/js"&gt;http://jaimersvr/AtlasWs/Webservice.asmx/js&lt;/A&gt; ]&amp;nbsp; and it should look like&amp;nbsp;the one below.. &amp;nbsp;Notice I did have to add one line, the this.path = &amp;lt;url to my webservice&amp;gt; ..&amp;nbsp; &lt;BR&gt;&lt;BR&gt;Type.registerNamespace(&lt;FONT color=#800000 size=2&gt;'AtlasSample'&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;BR&gt;AtlasSample.WebService=&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;function&lt;/FONT&gt;&lt;FONT size=2&gt;() &lt;BR&gt;{ &lt;BR&gt;&lt;/FONT&gt;//&amp;nbsp; These parameters can of course be set at runtime... In my case,&amp;nbsp; I hardcoded them here for brevity &lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.path = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"http://jaimersvr/AtlasWS/WebService.asmx"&lt;/FONT&gt;&lt;FONT size=2&gt; ; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.appPath = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"http://jaimersvr/AtlasWS/"&lt;/FONT&gt;&lt;FONT size=2&gt; ; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; cm=Sys.Net.ServiceMethod.createProxyMethod; cm(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"EchoString"&lt;/FONT&gt;&lt;FONT size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"s"&lt;/FONT&gt;&lt;FONT size=2&gt;); }&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;OK,&amp;nbsp; I think that is all we needed...&amp;nbsp; we are now ready to party w/ ajax.. :)&amp;nbsp;&amp;nbsp;To run the sample, simply click in the button in the gadget... &lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;WHY BOTHER using Atlas to call webservices instead of just plain old XmlHttp like we did on my last post??... &lt;BR&gt;Well, there is one nice reason to do this: Atlas does some nice JSON serialization on the back-end and front-end, so&amp;nbsp; the results come back as objects instead of as an XML file you need to parse...&amp;nbsp;&amp;nbsp; for example, my webservice returns an object...&amp;nbsp; that looks like this in C#: &lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;VolumeObject&lt;/FONT&gt;&lt;FONT size=2&gt; {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; At10m; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; At50m; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; At100m ; &lt;BR&gt;} &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;using Atlas, I do not need to write the XML de-serialization code ... &lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;/*digress: why this weird object&amp;nbsp;I started with a simple Echo function ... that returned what you sent.. but then I decided to do a more complex object .. so I thought an echo would do... here you get the echo at 10m ( LOUD ) at 50m ( LOud) and at 100m when it fades (loud) ....&amp;nbsp; you can stop gagging now :) */ &lt;/P&gt;
&lt;P&gt;The code for this sample is located &lt;A class="" href="http://sophiarodriguez.members.winisp.net/Shared%20Documents/CodeSnippets/atlasgadget.zip" mce_href="http://sophiarodriguez.members.winisp.net/Shared%20Documents/CodeSnippets/atlasgadget.zip"&gt;here&lt;/A&gt;,&amp;nbsp; there is a client side component ( sample.gadget) &amp;nbsp;and a server side component&amp;nbsp; ( AtlasWS ) ... You will as usual have to change the URLs in AtlasServiceProxy.js &amp;nbsp;from pointing to my servers to pointing to yours.. &lt;/P&gt;
&lt;P mce_keep="true"&gt;Cheers. .. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=783919" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Vista+Sidebar+Gadgets/default.aspx">Vista Sidebar Gadgets</category></item><item><title>Making REST calls and using state (aka cookies) from a sidebar gadget...</title><link>http://blogs.msdn.com/jaimer/archive/2006/09/28/Making-REST-calls-and-using-session-state-from-a-sidebar-gadget_2E002E002E00_.aspx</link><pubDate>Fri, 29 Sep 2006 05:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:776533</guid><dc:creator>jaimer</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/776533.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=776533</wfw:commentRss><description>&lt;P&gt;This will walk you through how to make REST (GET,POST) calls from a sidebar gadget using XmlHttp.. ( 20 mins or less, if you have asp .net) &lt;BR&gt;&lt;BR&gt;There are plenty of samples on the web for using XmlHttp, so will go quick and we will touch in a few of the 'more intricate' scenarios people have asked about: Cookies + Session State + redirects when sidebar gadgets call a back-end...&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&lt;BR&gt;The code for this sample is located &lt;A class="" href="http://jaimerodriguez.members.winisp.net/rest.zip" mce_href="http://jaimerodriguez.members.winisp.net/rest.zip"&gt;here&lt;/A&gt;; there is a &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;client side component (sample.gadget) -- note that for this sample, login.js script points to my local webserver..&amp;nbsp; you will have to update that to point to your back-end.. &lt;/LI&gt;
&lt;LI&gt;server side component ( UsernameSite) ..&amp;nbsp; this code uses ASP .NET, you can use any backend you want.. I used the easiest one for me. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Here is the gist of the Client-side code: &lt;BR&gt;&lt;STRONG&gt;loginFlyout.html&amp;nbsp; &lt;BR&gt;&lt;/STRONG&gt;Just&amp;nbsp; has form data... trivial HTML form prompting for username &amp;amp; password for form user authentication.&amp;nbsp;&amp;nbsp; The "useGet" determines if making a POST or GET request, though practically they are the same code. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;generic.js &lt;/STRONG&gt;has the function to get the XmlHttp object, first we check for native IE 7 object, if not possible we use MSXML.. &lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;function&lt;/FONT&gt;&lt;FONT size=2&gt; GetXMLHTTP () &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{ &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; xmlhttp = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;FONT size=2&gt; ; &lt;BR&gt;// this should be default path... using IE 7 native XML HTTP &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (window.XMLHttpRequest) &lt;BR&gt;{&lt;BR&gt;xmlhttp = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; XMLHttpRequest();&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; ( &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;typeof&lt;/FONT&gt;&lt;FONT size=2&gt; xmlhttp.overrideMimeType != &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;'undefined'&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;BR&gt;xmlhttp.overrideMimeType(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;'text/xml'&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;} &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;else&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (window.ActiveXObject) &lt;BR&gt;{&lt;BR&gt;xmlhttp = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; ActiveXObject(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Microsoft.XMLHTTP"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;} &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;else&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;throw&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"No XMLHTTP"&lt;/FONT&gt;&lt;FONT size=2&gt; ; &lt;BR&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; xmlhttp; &lt;BR&gt;} &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;login.js&amp;nbsp;&lt;/STRONG&gt;has the code to send the XmlHttp request..&amp;nbsp; Note that for this samples we used Synchronous calls... that is usually bad :( ... but it saves mein sample code and keeps it simpler so I left as an exercise for you to change .. &lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/P&gt;
&lt;P&gt;function&lt;/FONT&gt;&lt;FONT size=2&gt; submitForm() &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{ &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; item ; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; DataToSend = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;""&lt;/FONT&gt;&lt;FONT size=2&gt; ;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; x ; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000 size=2&gt;//parse the form to get the fields out ... and build the payload &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;for&lt;/FONT&gt;&lt;FONT size=2&gt; ( x = 0 ; x &amp;lt; document.form1.elements.length ; x++ ) &lt;BR&gt;{ &lt;BR&gt;DataToSend += document.form1.elements[x].id + &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"="&lt;/FONT&gt;&lt;FONT size=2&gt; + document.form1.elements[x].value + &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"&amp;amp;"&lt;/FONT&gt;&lt;FONT size=2&gt; ; &lt;BR&gt;} &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; xmlhttp = GetXMLHTTP() ;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;FONT size=2&gt; useGET = document.getElementById(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;'useGET'&lt;/FONT&gt;&lt;FONT size=2&gt;).value; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; ( useGET ) &lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;xmlhttp.open(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"GET"&lt;/FONT&gt;&lt;FONT size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"http://jaimersvr/UsernameSite/Logon.aspx?ReturnUrl=%2fUsernamesite%2fSessionPage.aspx&amp;amp;"&lt;/FONT&gt;&lt;FONT size=2&gt; + DataToSend, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;// Note this is a Synchronous call.. you should not do this..&amp;nbsp;call it async.. I did it this way to keep code simple .. .&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;xmlhttp.send();&lt;BR&gt;} &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;else&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;BR&gt;{&lt;BR&gt;xmlhttp.open(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"POST"&lt;/FONT&gt;&lt;FONT size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"http://jaimersvr/UsernameSite/Logon.aspx?ReturnUrl=%2fUsernamesite%2fSessionPage.aspx"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;BR&gt;xmlhttp.setRequestHeader(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Content-Type"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"application/x-www-form-urlencoded"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;// Note this is a Synchronous call.. you should not do this..&amp;nbsp;call it async.. I did it this way to keep code simple .. .&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;xmlhttp.send(DataToSend );&lt;BR&gt;} &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#008000 size=2&gt;// This is example for a flyout communicating with main document ... &lt;BR&gt;// check the System.Gadget.document documentation &lt;/FONT&gt;&lt;FONT size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;System.Gadget.document.getElementById (&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;'result'&lt;/FONT&gt;&lt;FONT size=2&gt;).innerHTML = xmlhttp.responseText; &lt;/P&gt;
&lt;P&gt;} &lt;/P&gt;
&lt;P&gt;That is all the client side code ... :)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;I will not explain the server side code unless I start getting requests for it..&amp;nbsp; I am guessing any one who is familiar with ASPX will know how to install it ... and those that are not familiar will be OK just knowing that REST works well from within sidebar.. &lt;/P&gt;
&lt;P&gt;Here is what the end to end sample does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The xmlhttp call is doing is calling&amp;nbsp;the login.aspx page on the server side ...&amp;nbsp;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;At successful login, the Loginaspx does a Redirect to SessionPage.aspx, &lt;/LI&gt;
&lt;LI&gt;SessionPage.aspx merely displays the status of some session variables..&amp;nbsp;&amp;nbsp; Every time you call this page, the variables get increased.. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Here is how to run it:&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Click the "ShowFlyout"&amp;nbsp; URL in the gadget &lt;/LI&gt;
&lt;LI&gt;Enter "test" (minus quotes) as Email address &lt;/LI&gt;
&lt;LI&gt;Enter "test" (minus quotes) as Password &lt;/LI&gt;
&lt;LI&gt;Click GetSession Data &lt;/LI&gt;
&lt;LI&gt;Repeat&amp;nbsp;previous step to see the variables get incremented&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Add a new instance of this same gadget to the sidebar and&amp;nbsp;repeat the&amp;nbsp;first 4 steps; notice that multiple instances of the gadget are sharing the same back-end session data ...&amp;nbsp; {good for some people, is it&amp;nbsp;bad for any?}&amp;nbsp;&lt;BR&gt;&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;Here are some of my observations: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Session Variables work fine... even the cookie is persisting fine ... [not sure who is doing the work, I am guessing xmlhttp] &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;Here are the gotchas or issues I saw (which for most part might not be an issue): &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;IE in Windows Vista runs in a different trust level, called Protected Mode...&amp;nbsp; Read about it &lt;A class="" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/ProtectedMode.asp" mce_href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/ProtectedMode.asp"&gt;here&lt;/A&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;This translates to the cookie we are persisting in our gadget and the cookie IE is reading&amp;nbsp;are *not* shared..&amp;nbsp; You can have a separate cookie for each if that works for your model (e.g. the cookie just tells you my login or some thing like that)... but as far as passing state, no deal..&amp;nbsp;&amp;nbsp;[ I have some ideas on how to get that to work, but might be too much] &lt;/LI&gt;
&lt;LI&gt;I have also seldomly experienced an issue where the domain cookie that is to be persisted is not incrementing..&amp;nbsp; I have not figured this out.. it happens seldomly and goes away on its own..&amp;nbsp; If you are having problems with cookies, you can verify if things are working fine using a utility like &lt;A class="" title="IE CookieView" href="http://www.nirsoft.net/utils/iecookies.html" target=_blank mce_href="http://www.nirsoft.net/utils/iecookies.html"&gt;IECV&lt;/A&gt;.. &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;Hope that was useful; if the instructions are too hard ... let me know ..&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=776533" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Vista+Sidebar+Gadgets/default.aspx">Vista Sidebar Gadgets</category></item><item><title>The basic wiring for a vista sidebar gadget..</title><link>http://blogs.msdn.com/jaimer/archive/2006/09/28/The-basic-wiring-for-a-vista-sidebar-gadget_2E002E00_.aspx</link><pubDate>Thu, 28 Sep 2006 22:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:776449</guid><dc:creator>jaimer</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/776449.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=776449</wfw:commentRss><description>&lt;P&gt;[This should be read as a supplement to &lt;A href="http://microsoftgadgets.com/Sidebar/DevelopmentOverview.aspx" mce_href="http://microsoftgadgets.com/Sidebar/DevelopmentOverview.aspx"&gt;gadget development verview&lt;/A&gt;&amp;nbsp;].&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Writing a gadget is quite easy.. It is just HTML and a little bit of wiring up notifications for docking + undocking,&amp;nbsp;visibility, etc.&amp;nbsp;&amp;nbsp;I am hoping this post and&amp;nbsp;helps you have a gadget with flyouts, notification for docking/undocking,&amp;nbsp; saving settings, etc. in less than&amp;nbsp;20 mins.. &lt;/P&gt;
&lt;P&gt;---&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A class="" href="http://jaimerodriguez.members.winisp.net/basicwiring.zip" mce_href="http://jaimerodriguez.members.winisp.net/basicwiring.zip"&gt;sample code is here&lt;/A&gt; packaged in zip, with a VS solution so you can edit the files easily from Visual Studio.&amp;nbsp;&amp;nbsp;&lt;BR&gt;To install, extract the zip file to &lt;BR&gt;“%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets\Sample.Gadget”&lt;/P&gt;
&lt;P&gt;Should end up with a structure similar to this: (with only a few files highlighted) &lt;/P&gt;
&lt;P&gt;\Users\jaimer\AppData\Local\Microsoft\Windows Sidebar\Gadgets\Sample.Gadget&amp;nbsp; &lt;FONT color=#0000ff&gt;the full path to our gadget directory &lt;/FONT&gt;&lt;BR&gt;...\Sample.Gadget\en-us\gadget.xml&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;The manifest file... relatively easy to understand&lt;/FONT&gt;.. &lt;BR&gt;...\Sample.Gadget\en-us\simplest.html&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;this will be the gadget file used for this sample&amp;nbsp; -- the gagdget knows to load this file because we told it in the gadget.xml &lt;BR&gt;&lt;/FONT&gt;...\Sample.Gadget\en-us\settings.html&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;the UI for the gadget's settings..&lt;BR&gt;&lt;/FONT&gt;...\Sample.Gadget\en-us\css\main.css&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;centralized place for our&amp;nbsp; style sheets&lt;/FONT&gt; ...&lt;BR&gt;\Gadgets\Sample.Gadget\en-us\js\generic.js&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;I have put some generic JS code here..&amp;nbsp;[stuff that I use for all my gadgets]&amp;nbsp;..&lt;/FONT&gt; &lt;/P&gt;
&lt;P&gt;A few of the interesting snippets in this sample gadget is: &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;gadget.xml&amp;nbsp;- &lt;/STRONG&gt;aka gadget manifest&lt;BR&gt;Only file name that can not be changed; sidebar specifically looks for this filename&lt;BR&gt;Most relevant entry is the &lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;base&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;type&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;HTML&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;apiVersion&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;1.0.0&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;src&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Simplest.html&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;/&amp;gt; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;This tells the sidebar gadget what file to load as entrypoint.. &lt;/P&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;/STRONG&gt;
&lt;P&gt;&lt;BR&gt;&lt;STRONG&gt;Simplest.html -- our gadget user interface &lt;BR&gt;&lt;/STRONG&gt;The HTML file loaded by sidebar; aka our UI...&amp;nbsp; interesting snippets: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;include for&amp;nbsp;the stylesheets and JS files: &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;link&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;href&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="css/main.css"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;rel&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="stylesheet"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;type&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="text/css"/&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;script&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;src&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="js/generic.js"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;type&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="text/javascript"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;language&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="javascript"&amp;gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;script&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;script&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;src&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="js/custom.js"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;type&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="text/javascript"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;language&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="javascript"&amp;gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;script&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT color=#000000 size=2&gt;wired the Init () call that will do all the wiring work &lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;body&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;onload&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="init();"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;class&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="DockedModeDisplayArea"&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp; &lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;STRONG&gt;Generic.js &lt;BR&gt;&lt;/STRONG&gt;The wiring is done in the init function.. we do a bit of the wiring here: &lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;function&lt;/FONT&gt;&lt;FONT size=2&gt; init ( ) &lt;BR&gt;&lt;/FONT&gt;{ &lt;BR&gt;System.Gadget.settingsUI = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"settings.html"&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//&lt;FONT color=#008000 size=2&gt;This tells the gadget the HTML file to launch for settings&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;System.Gadget.onSettingsClosed = settingsClosed; &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//wire ourselves to settings closed event to save them &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;System.Gadget.visibilityChanged = visibilityChanged; &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// stop working if we are not visible &lt;/FONT&gt;&lt;FONT size=2&gt;System.Gadget.onUndock = chkdockedState; &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//let me know if I get undocked so I can look different &lt;/FONT&gt;&lt;FONT size=2&gt;System.Gadget.onDock = chkdockedState;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;System.Gadget.onShowSettings = showSettings ; &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// let me know if settings are being shown &lt;/FONT&gt;&lt;FONT size=2&gt;System.Gadget.Flyout.onHide = flyoutHiding; &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//let me know if flyout is showing/hiding. I can pass data to it via document property&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;System.Gadget.Flyout.onShow = flyoutShowing; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;that is all the code&amp;nbsp; needed to wire every thing side bar does ( drag drop is not some thing you can wire into .. Pretty easy! The rest is your business logic to populate what happens on each action.. and the code to show the Flyout&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;custom.js &lt;/STRONG&gt;&lt;BR&gt;Notice that simplest.html has &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;a&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;href&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=""&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;onclick&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;="showFlyout('login', 10000);"&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Show Flyout&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;a&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;br&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;/&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;This will be the code to show our flyout . showing it is as simple as setting:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;&lt;FONT size=2&gt;System.Gadget.Flyout.file =&amp;nbsp; "login&lt;/FONT&gt;&lt;FONT size=2&gt;Flyout.html"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;;&amp;nbsp; //file name to be shown.. &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;System.Gadget.Flyout.show = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;To hide the Flyout, set: &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;System.Gadget.Flyout.show = &lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;The code I am showing hides the flyout after 10 seconds.. &lt;BR&gt;I hide it for no reason other than to show you how to hide it.. &lt;BR&gt;Note that the Flyout is only visible when the gadget has focus.. if gadget loses focus, the flyout hides automatically.&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;settings.html&lt;BR&gt;&lt;/STRONG&gt;This file shows UI for entering settings... &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Notice that the sidebar puts the "frame" for the settings screen... &lt;BR&gt;Sidebar &lt;/FONT&gt;&lt;FONT size=2&gt;handles the frame title, OK, Cancel button ... and you get the notification via the System.Gadget.onSettingsClosed event..&amp;nbsp; to cancel this dialog from closing [say it&amp;nbsp;failed validation] you can listen for the onClosingEvent.&amp;nbsp; You can see all the sample logic, to load and save settings inside the settings.js file &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;That is it! With this quick sample you should have a gadget rendering UI in no time.. &lt;/FONT&gt;&lt;FONT size=2&gt;Unfortunately all we can do now is render UI, maybe desktop status, a game or any thing else that works disconnected.. Next post we will wire this to some data :) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;To run the sample,&amp;nbsp; &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;add your gadget to the vista sidebar&lt;/LI&gt;
&lt;LI&gt;Click on the ShowFlyout&amp;nbsp; Anchor &lt;/LI&gt;
&lt;LI&gt;Click any where out side of the gadget to have the flyout go away&amp;nbsp; (or wait 10 secs) &lt;/LI&gt;
&lt;LI&gt;Right click any where in the gadget &lt;/LI&gt;
&lt;LI&gt;Select Options, to show the SettingsUI &lt;/LI&gt;
&lt;LI&gt;Click OK -- you will see a validation error appear.... this was again added randomly as an example &lt;/LI&gt;
&lt;LI&gt;Click OK again &lt;/LI&gt;
&lt;LI&gt;Start now hacking away at the gadget and make some thing cool&amp;nbsp; :) &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The whole sample is &lt;A class="" href="http://jaimerodriguez.members.winisp.net/basicwiring.zip" mce_href="http://jaimerodriguez.members.winisp.net/basicwiring.zip"&gt;here&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=776449" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Vista+Sidebar+Gadgets/default.aspx">Vista Sidebar Gadgets</category></item></channel></rss>