How to control the ordering of tiles in custom strips in Windows Media Center for Windows Vista
A couple of weeks ago, I posted an item describing how to add up to 2 custom strips to the Windows Media Center Start menu with up to 5 tiles each. As I was working on the examples for that blog post, I noticed an annoying behavior - when creating a strip with multiple tiles, the tiles seemed to appear in a random order from left to right within the strip.
After talking to a couple of developers and looking at some of the code, I found out that it is possible to control the order of the tiles in a custom strip, but it is non-intuitive to say the least. To help folks combat this non-intuitiveness I'm going to post this blog post and this information will be included in a future build of the Windows Media Center SDK as well.
The following registry value is used to sort the tiles based on the order in which they were installed, and then Windows Media Center selects the first 5 tiles that it finds based on the order that they were installed (from oldest to newest), and displays them as tiles in the custom strip on the Start menu:
- Registry root: HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
- Key name: SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Extensibility\Categories\<custom category name>\<entry point GUID>
- Value name: TimeStamp
- Value data type: REG_DWORD
- Value data: The number of seconds that have elapsed since midnight on January 1, 2000 C.E.
The tricky part here is that if the TimeStamp value is the same for multiple entry points (tiles), then the sort order is indeterminate. This is compounded by the fact that if you register your application using RegisterMceApp.exe or the RegisterApplication API, the TimeStamp values will nearly always be set to identical values because the operations that this EXE and API perform are fast enough to complete within a second.
In order to control the exact order that tiles appear in a custom strip that you add to the start menu, you will need to modify the TimeStamp values to be unique and sequential so that the tile you want to appear on the far left has the smallest TimeStamp value and the tile you want to appear on the far right has the highest TimeStamp value.
The easiest way I have found to accomplish this is the following:
- Register your application as usual
- Locate the ...\Extensibility\Categories\ sub-key for the <entry point GUID> that you want to appear on the far left in your custom strip
- Use that TimeStamp value in the registry as the baseline
- Locate the ...\Extensibility\Categories\ sub-key for the <entry point GUID> that you want to appear 2nd, and change the last digit of the TimeStamp value to be 1 higher than the baseline value defined in step 3
- Repeat step 4 for the remaining 3 <entry point GUID> TimeStamp values
In order to demonstrate this concept, I have updated the Start menu customization example to include a registry file named TestApp1Ordered.reg.
If you register TestApp1 as a custom strip using these instructions and then launch Windows Media Center, you will see the tiles listed in a non-sequential order. If you then merge in TestApp1Ordered.reg to your registry and restart Windows Media Center, you will see the tiles displayed in sequential order from left to right.
If you look at TestApp1Ordered.reg in a text editor such as Notepad, you can see that I use the baseline value of DWORD:0c7e59da for Entry Point 1 and then increment this value by 1 for each subsequent entry point.
Please note that I listed the HKEY_CURRENT_USER versions of the registry values in TestApp1Ordered.reg, so if you register the application for all users, you will need to update the syntax of TestApp1Ordered so that it works correctly.
A couple of additional notes:
If you are planning to create an MSI package to install your Windows Media Center application (which I strongly recommend as a ship vehicle for your application!), then you can directly add TimeStamp registry values in sequential order in the Registry table of the MSI to control the placement of tiles in your custom strip.
If you register more than 5 entry points for a category and then add that category as a custom Start menu strip, Windows Media Center will only select the first 5 entry points to display as tiles in the custom strip. Make sure that the 5 entry points that you want to appear have the 5 lowest TimeStamp values relative to the other entry points in the same category to ensure that they appear as you intend.
There are 2 locations where Windows Media Center creates TimeStamp registry values when you register applications. For the purposes of ordering tiles on custom Start menu strips, make sure that you modify the TimeStamp values under ...\Extensibility\Categories and not the values under ...\Extensibility\Entry Points