Saturday, 30 June 2007

Steve Nagys' Tips and Tricks

Steve Nagy has some great tips and tricks posted on his blog after creating his Vista Gadget called SurfWatch. I'm now downloading Orcas to see if that's any use with making Gadgets as the current Visual Studio doesn't provide much help at all.

1. Use Visual Studio Codename 'Orcas'. The intellisense on JavaScript makes it extremely useful.
2. When using flyouts, set the style of the page body tags to remove the padding and margin, otherwise your flyout doesn't line up with your gadget.

3. You can also use the g:background tag for your flyout window to ensure transparency.

4. You can set data and call functions in the flyout from your main gadget window by calling against it's DOM. For example, if you had a textbox in your flyout, you would access it like this:

var flyoutDOM = System.Gadget.Flyout.document;
var myText = flyoutDOM.getElementById('myText');

Likewise, if you have registered functions in your DOM in your flyout, they can be called the same way. This allows for a form of communication between your two gadget windows.

5. Docked and undocked versions of your gadget actually run under the same html file. If you want them to look different and have different contents, keep this in mind when designing your gadget.

6. Emailing gadgets is tricky! Since they are essentially a zip file, most email servers will detect that the attachment contains items with JavaScript, and may zap it. Not sure how to get around this yet!

7. There is a mime-type for gadgets:
application/x-windows-gadget

No comments: