Theme question.

  • Thread starter Thread starter pnp
  • Start date Start date
P

pnp

Hi all,
Could I use an external dll (that windows also use for it's themes) from
which my application could load it's graphics at runtime? Basically I wan't
to be able to select the styles for my application without changing the
windows general appearance.

Thanks,
Peter.
 
Hi pnp,

I believe you mean by skins / style.

Well you can write something that can control which skins you one. One good example of a .net skin / styles you can use.

http://www.dotnetmagic.com/

I believe there is more.

Good Luck. Correct me if i am wrong.
 
Thanks Chua on your so soon reply, but I wondered if I could use the windows
theme files...


Chua Wen Ching said:
Hi pnp,

I believe you mean by skins / style.

Well you can write something that can control which skins you one. One
good example of a .net skin / styles you can use.
 
Hi pnp,

I never tried before. But you should look into uxtheme.dll. For more info how to call them, check this.

http://pinvoke.net

To get what is the current UI, at least i know how to do a bit.. ee.. actually learn it from codeproject.

I believe if you can do it if you know the right way to call it. Below is an example of getting what are the styles using for the current windows.

The themes are stored in the registery part of windows.

//references: http://www.thecodeproject.com/csharp/xptheme.asp
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;

namespace TestVisualStyles
{

class CheckThemeClass
{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("Current Windows Theme = {0}", CurrentTheme());
Console.WriteLine("Windows Theme Active = {0}", IsThemeActive());
Console.WriteLine("Application Theme Active = {0}", IsAppThemed());
Console.ReadLine();

}

public enum Themes

{
WindowsClassic,
XPBlue,
XPGreen,
XPSilver
}

public static Themes CurrentTheme()
{
RegistryKey key =
Registry.CurrentUser.OpenSubKey(
@"Software\Microsoft\Windows\CurrentVersion\ThemeManager");
if (key != null)
{
if ("1" == (string) key.GetValue("ThemeActive"))
{
string s = (string) key.GetValue("ColorName");
if (s != null)
{
if (String.Compare(s, "NormalColor", true) == 0)
return Themes.XPBlue;
if (String.Compare(s, "HomeStead", true) == 0)
return Themes.XPGreen;
if (String.Compare(s, "Metallic", true) == 0)
return Themes.XPSilver;
}
}
}
return Themes.WindowsClassic;

}

[DllImport("uxtheme.dll", SetLastError=true)]
public static extern bool IsThemeActive();

[DllImport("uxtheme.dll", SetLastError=true)]
public static extern bool IsAppThemed();
}
}

Hope it helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top