News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

QA: How to install a Today theme file?

By Joao Paulo Figueira, June 02, 2003.
Print version

Question

How do I programmatically install a Today theme?

Answer

To change the appearance of your Pocket PC 2002 Today screen, you have to options: select a theme file, or a wallpaper. Themes are more complex than wallpapers. Besides having a background image, themes also implement system-wide colour schemes. Wallpapers are mere replacements of the current skin background image. Installing a Today screen theme is a bit more complex than installing a wallpaper.

To install a Today screen theme do the following:

  • Copy the theme file to the \Windows folder. Optionally, you can also copy it to the \My Documents folder. The Today applet in Settings will search for skin files in both folders.
  • Under HKEY_CURRENT_USER\Software\Microsoft\Today, delete the value UseStartImage. This is necessary because some themes, notably 'Bliss', use this value to determine the bitmap number to use. Most themes will not use it and, when changing from 'Bliss' to any other theme file, the presence of particular value will make your new theme not to display its bitmap.
  • Use wceload.exe to install the theme with the following command line parameters: '/safe /noui /nouninstall /delete 0 \Windows\skinfile.tsk'.
  • Under the same key, set the SZ value 'Skin' to your theme file's full path name.
  • Use the magical touch: SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);.

Here is some sample code:

HKEY hKey; LONG lRet; TCHAR szCmdLine[MAX_PATH+1]; TCHAR* pszFile = _T("\\Windows\\Fire.tsk"); // The theme file // // Set the theme // lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Today"), 0, 0, &hKey); if(ERROR_SUCCESS == lRet) { RegDeleteValue(hKey, _T("UseStartImage")); wcscpy(szCmdLine, _T("/safe /noui /nouninstall /delete 0 ")); wcscat(szCmdLine, pszFile); if(::CreateProcess(_T("\\Windows\\wceload.exe"), szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &amppi)) { ::WaitForSingleObject(pi.hProcess, INFINITE); RegSetValueEx(hKey, _T("Skin"), 0, REG_SZ, (BYTE*)pszFile, sizeof(TCHAR) * (wcslen(pszFile) + 1)); RegCloseKey(hKey); } // // Broadcast the update today message // ::SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0); }

Installing a wallpaper is much simpler, but you have to perform a previous step. Your wallpaper file must be copied into the windows directory with the name of 'tdycust'. Assuming you have a wallpaper file named 'wallpaper.gif' in the \My Documents folder, here is the code you would use to set it:

// // Set the wallpaper // lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Today"), 0, 0, &hKey); if(ERROR_SUCCESS == lRet) { SetKeyValue(hKey, _T("WallFile"), _T("\\windows\\tdycust.gif")); SetKeyValue(hKey, _T("Wall"), _T("Wallpaper")); SetKeyValue(hKey, _T("Watermark"), _T("tdycust.gif")); RegCloseKey(hKey); // // Broadcast the update today message // ::SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0); }

To remove the wallpaper: delete the 'Watermark' value, set 'WallFile' to an empty string, and broadcast the WM_WININICHANGE message, just like in the above example.

Related resources:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House