This project is read-only.

Applying Windows 7 Theme Files

Coordinator
Jan 29, 2012 at 8:30 PM
Edited Jan 29, 2012 at 9:20 PM

This article describes how to programmatically apply Windows Theme file to your Desktop.

Windows 7 provides a nice theme functionality that is powerful to configure Desktop Background Wallpaper. All features of Windows 7 themes are described in this article:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb773190(v=vs.85).aspx

Theme files have many options, like  Desktop Background Slide Show so that wallpapers rotate at specific intervals and nice fade in fade out effect is used when pictures are switching. 

http://msdn.microsoft.com/en-us/library/windows/desktop/aa511285.aspx

All these make theme switching non invasive, yet still thrills and delights users. 

After all this goodness, it seems that Windows 7 has a major flaw of not providing a way for Apps to set their own custom theme. So the only way to set a new theme is to go through Personalization Control Panel. There is no other way! There is no API, no Win32 API, no shell script, no COM API to set custom theme file. Officially suggested way is through ShellExecute or Shell32.dll, which again pops up Personalization Control Panel.

Because of this OS limitation, upon setting new theme, Picturethrill will

  1. Open Personalization Control Panel through ShellExecute
  2. Dismiss it through UIAutomation, by Closing Control Panel window. 

This will result in user experience where user will briefly see Control Panel pop up, but then instantly dismissed. Although not ideal, this is the only option that is feasible.

Thank you,

Nikolai Aristov

 

References:

http://adventuresinosd.blogspot.com/2008/11/setting-windows-xp-themes.html

To apply theme file and open Control Panel Personalization window:

Cmd Script:

 rundll32.exe Shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /File:"C:\Users\YourUserName\AppData\Local\Microsoft\Windows\Themes\Picturethrill.theme"

Win32:

ShellExecute(NULL, NULL, L"C:\\Users\\YourUserName\\AppData\\Local\\Microsoft\\Windows\\Themes\\Picturethrill.theme", NULL, NULL, SW_SHOW);

Unfortunately other SW_* flags, like SW_HIDE, SW_SHOWMINNOACTIVE don't have any effect on opened Control Panel window.