In April, Long Zheng brought more attention to a neat applet within Windows Vista called the Mobility Center. It wasn't until recently, however, he ranted to me about its continued lack of attention by ISVs and challenged me to a) figure out how tiles work and b) create a tile myself. After some preliminary Google querying, I came across specific implementation information in the Windows Vista OEM Preinstallation Kit, WindowsMobilityCenter-OEMDeployment.rtf to be specific (pdf'ed for shrinkage purposes). Upon glance, you'll notice the acronym OEM plastered everywhere. Mobility Center's extensibility, sadly, was designed solely for OEM use.
As you'll read in the document, there are two types of Tiles. Static and Dynamic. Static Tiles contain an icon, a line of text, a control (button, slider, or drop-down) and its name at the bottom. Nothing more, nothing less. Dynamic Tiles contain all the properties of a Static Tile but also offer the ability to 'refresh' the Tile live, programatically, enhancing the UI experience at the expense of code complexity (i.e. the Volume Tile).
Long's request, thankfully, only necessitated the creation of a Static Tile which only requires a hand full of code. Dynamic Tiles force developers into the fiery depths of COM of which I'll get into at some other time.
Following the guide, I created the necessary registry keys, assigned them values pointing to string and icon resources in my executable, and wrote some code to shut off the display. (If you're a developer and wondering why I didn't just hackishly send a window message to my desktop or all the windows on my desktop with three lines of code, read this article now).
Bare minimum registry tinkering required:
- TileOrder (REG_MULTI_SZ)
- OEMName (REG_EXPAND_SZ)
- Tile registry values (REG_EXPAND_SZ)
- TileName (pointing to string resource)
- Icon (pointing to 32x32 and 48x48 icon resource)
- StatusText (pointing to string resource)
- ButtonAction (command to execute)
- ButtonLabel (pointing to string resource)
- RunOnDesktop (REG_DWORD), to enable use of Mobility Center on non-mobile platforms. (must be on supported Windows Vista SKU)
Before you go off creating your own tiles, swamping machines with your viral Tiles, I must emphasize the following points:
- The OEMName registry value should not be blindly overwritten by your registry script or Tile installation routine. Doing so can render Tiles missing in action and/or show unwanted text in the Mobility Center.
- The text Customized by is hard-coded. Again, Mobility Center's extensibility was designed for OEM use, therefore a company name would normally proceed. My Display Off Tile contains the text resource "various third parties" to keep it open for third party use.
- I am developing a management utility of sorts to allow independent developers to put out their own Tiles without having to worry about duplicating my OEM Tile detection logic, manipulate the tile order, write an installer, etc. I'm looking for suggestions and comments in this area (i.e. should I mimic .Gadget files?)
- Read the documentation.