bsp-620w

Battlestations Pacific Gadget

Previously, I discussed the creation of the NVIDIA Status Gadget that I’d created back around the time of the Windows Vista launch. I recently finished up a project to create another Windows Vista Sidebar gadget, this time for EIDOS Interactive

This new gadget is essentially an electronic version of a printed calendar that EIDOS created as a marketing tie-in for their new game Battlestations: Pacific.  This calendar featured a variety of WWII-style pinup girls in various poses, as were commonly seen painted on the nose of Allied aircraft during the war.  In the BSP game, you can apply the pinups to the aircraft you fly.

Compared to the NVIDIA Status Gadget, the BSP gadget was a much more design-intense project.  The creative team at EIDOS had already created a printed version of their calendar and the gadget had to closely match the same design. There were dozens of pieces of artwork that needed to be prepared and precisely positioned.

Furthermore, the BSP gadget was much more interactive.  The NVIDIA gadget simply displayed the status information and provided a single link to their website.  In comparison, the new BSP gadget had to allow the user to step back and forth from month to month, as well as step back and forth through the available pinup pictures.  Additionally, there were popup information boxes and a variety of web links to manage.

However, unlike the NVIDIA gadget, the BSP gadget did not require any special access to things like video drivers, so there were no special Active-X objects to create this time around.

Gadget Viewer

The one special requirement we did have for this project was that EIDOS wanted the gadget to run on Windows XP as well as Vista.   Since Windows XP doesn’t natively support Sidebar gadgets, this meant creating a special viewer application that would host the gadget on XP.

In the HTML file for the gadget, the changes were minimal.  All I really had to do was change the places where the System.Gadget object was accessed.  This was really just a few places that checked the docked/undocked status.  Once I did this, the code ran just fine in the regular Internet Explorer browser when I double-clicked the main HTML file.

For the viewer application, I created a .NET C# project.  All I needed was a blank window and the Internet Explorer browser control.  The rest was a matter of making it load the right files and react to the button event that would toggle the size between “docked” and “undocked” (i.e. small and big). 

Ultimately, the main difference with the XP version is that it has a standard Windows title bar and an extra button in the body of the window.

May 27th, 2009 by Mike Fulton
Categories: Microsoft, Web Design & Programming, Windows
NVIDIA Graphics Gadget

NVIDIA Graphics Gadget

I first got involved in creating Vista Sidebar gadgets back when Windows Vista was still in beta release.  I was asked by NVIDIA to create a gadget that would display the type of graphics card you have installed, the current NVIDIA driver version, how much graphics memory was on the card, and the current operating temperature.  And if you had two cards working in NVIDIA’s SLI mode, it needed to show the separate information for each of the installed cards.  Lastly, it had to be able to generate an alarm if the temperature got too hot.

It sounds like it’s really not that hard, provided you have a means of collecting those various tidbits of information about the installed graphics card(s), but it was still a challenging project in some ways.  For one thing, when I started the project, the documentation about creating gadgets was brand new and still undergoing occasional changes.   The first few weeks I was working on the gadget, the documentation changed 3 times.

Also, there were really no samples to look at except for those gadgets included with the Vista beta.   Some decent gadgets are included there, but none of them were created with the goal of being sample code for developers.  Between the lack of samples and the shifting documentation, there were a lot of questions about “Can you do xxx in a gadget?” that nobody seemed able to answer quite yet.

What Is A Gadget?

Gadgets are basically small, specialized webpages that exist independently of any visible browser.  Windows Vista isn’t the first system to have such an animal.  The Macintosh OS X has the Dashboard and “widgets”, and Yahoo has their Yahoo Widget Engine, previously known as Konfabulator.  All of these are slightly differnet flavors of the same idea.  They are all created with a mix of browser-compatible artwork, HTML, CSS, and your favorite scripting language. Generally, they can do almost anything you can do on a regular webpage, but are typically designed to show a specific and limited amount of information.

There’s usually some manifest file gluing it all together.   For Windows Sidebar Gadgets, there’s an XML document that specifies all the information needed by the system.

Gadget Scripting

Most gadgets need to allow for some interactivity with the user, or with web servers, database servers, or who knows what.  To manage this, you can use any client-side scripting language that is supported natively by Internet Explorer.  That means Javascript or VBScript for most people.  The good news is, you don’t have to worry about targetting 14 different combinations of browser type and version. 

Javascript code running in a gadget has some additional restrictions compared to code running in a standard browser.  Certain things just don’t work, such as alerts or input prompts.   And you’re not able to open new windows.

On the other hand, gadgets also have some additional capabilities available through Javascript compared to code running in a standard browser.  For example, they have access to a special system object class that provides access to variety of things that Javascript would ordinarily not be able to access.

Gadget Security

Gadgets have to live within a security model that’s more or less similar to what a regular webpage has, but there are some important differences.  The main example is that the System.Gadget object class allows your script code to access to the local file system and a variety of other things that Javascript would ordinarily not be able to access.

Another nice thing is that because gadgets are based locally instead of coming from a web server, the usual security restrictions for not allowing cross-domain script access have been lifted.  Your Javascript code can make Ajax requests of any domain as desired.

The NVIDIA Status Gadget

The NVIDIA Status Gadget needed to be able to display information that could only be obtained from one source: directly from the NVIDIA graphics drivers.  Since it was not possible to access the drivers directly from the gadget’s Javascript code, I needed an alternative way to get the information.  So what I did was to create an Active-X control that implemented an object that was accessible from Javascript.  This control was basically just a wrapper for the calls in the NVIDIA drivers that returned the desired information.

This got the job done, ultimately, but it did complicate development at first.  Before I could write the gadget, I needed the Active-X object, and before I could really test that the Active-X object was working right, I needed the gadget as a client.  Ultimately, the Active-X control wasn’t really that complicated, as such things go, but it was an added task that most gadgets don’t have to worry about.