internal static bool IsCombinationDefined(string className, int part) { bool returnVal = false; if (!IsSupported) { if (!VisualStyleInformation.IsEnabledByUser) { throw new InvalidOperationException(SR.VisualStyleNotActive); } else { throw new InvalidOperationException(SR.VisualStylesDisabledInClientArea); } } if (className == null) { throw new ArgumentNullException(nameof(className)); } IntPtr hTheme = GetHandle(className, false); if (hTheme != IntPtr.Zero) { // IsThemePartDefined doesn't work for part = 0, although there are valid parts numbered 0. We // allow these explicitly here. if (part == 0) { returnVal = true; } else { returnVal = UxTheme.IsThemePartDefined(hTheme, part, 0).IsTrue(); } } //if the combo isn't defined, check the validity of our theme handle cache if (!returnVal) { using (ThemeHandle tHandle = ThemeHandle.Create(className, false)) { if (tHandle != null) { returnVal = UxTheme.IsThemePartDefined(tHandle, part, 0).IsTrue(); } //if we did, in fact get a new correct theme handle, our cache is out of date -- update it now. if (returnVal) { RefreshCache(); } } } return(returnVal); }