GStar
GStar

Reputation: 55

How to change Current theme to Window classic Theme in Window7 at runtime

I am working with ASP.net and C# . Now, I have developed a web application. I want to change the current theme to windows classic theme in Window7(IE8) because my design is disordered when other theme used. Could I change theme at run time? Could I do this OnPreInit() Event. Please help me .

With regards,

Upvotes: 1

Views: 1532

Answers (1)

Jeremy Thompson
Jeremy Thompson

Reputation: 65712

You should fix your CSS rather than change the entire windows theme to make it work...

Plus you cant launch a Process on the client from an ASP.Net, never the less here is the answer for non-web applications:

Ref: http://davidrobertmattson.com/wordpress/?p=48

//Sets the current theme
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.FileName = “rundll32.exe”;
string startuppath = Application.StartupPath.ToString();
string Arguments = “Shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /File:\”C:\\Windows\\Resources\\Themes\\Windows Classic.Theme\”";
startInfo.Arguments = Arguments;
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForInputIdle();

IntPtr p = exeProcess.MainWindowHandle;
ShowWindow(p, 1);
SendKeys.SendWait(“{enter}”);
}
}
catch
{
// Log error.
}

Upvotes: 2

Related Questions