06 Oktober, 2007

Tip : Vista Gadgets

Today I completed a Vista Gadget called SurfWatch. You can download it here. I learnt a lot while creating this Gadget. My Javascript skills are are a

lot better now, and of course I learnt some of the Gadget API. Here's some tips that might be useful to you if you are writing gadgets also.

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

Tidak ada komentar: