public static bool VisualStylesEnabled() { // Check if RenderWithVisualStyles property is available in the Application class (New feature in NET 2.0) Type t = typeof(Application); System.Reflection.PropertyInfo pi = t.GetProperty("RenderWithVisualStyles"); if (pi == null) { // NET 1.1 OperatingSystem os = System.Environment.OSVersion; if (os.Platform == PlatformID.Win32NT && (((os.Version.Major == 5) && (os.Version.Minor >= 1)) || (os.Version.Major > 5))) { DLLVersionInfo version = new DLLVersionInfo(); version.cbSize = Marshal.SizeOf(typeof(DLLVersionInfo)); if (Win32.DllGetVersion(ref version) == 0) { return((version.dwMajorVersion > 5) && ThemeRoutines.IsThemeActive() && ThemeRoutines.IsAppThemed()); } } return(false); } else { // NET 2.0 bool result = (bool)pi.GetValue(null, null); return(result); } }
private bool EnsureTheme(string strName) { if (ThemeRoutines.IsThemeActive() && !m_pLoadedThemes.ContainsKey(strName)) { IntPtr pTheme = IntPtr.Zero; pTheme = ThemeRoutines.OpenThemeData(m_cParent.Handle, strName); if (pTheme != IntPtr.Zero) { m_pLoadedThemes.Add(strName, pTheme); return(true); } return(false); } return(true); }