public void SetParameters(string className, int part, int state) { if (theme != IntPtr.Zero) { last_hresult = VisualStyles.UxThemeCloseThemeData(theme); } if (!IsSupported) { throw new InvalidOperationException("Visual Styles are not enabled."); } this.class_name = className; this.part = part; this.state = state; theme = VisualStyles.UxThemeOpenThemeData(IntPtr.Zero, this.class_name); if (IsElementKnownToBeSupported(className, part, state)) { return; } if (theme == IntPtr.Zero || !VisualStyles.UxThemeIsThemePartDefined(theme, this.part)) { throw new ArgumentException("This element is not supported by the current visual style."); } }
public static bool IsElementDefined(VisualStyleElement element) { if (!IsSupported) { throw new InvalidOperationException("Visual Styles are not enabled."); } if (IsElementKnownToBeSupported(element.ClassName, element.Part, element.State)) { return(true); } IntPtr theme = VisualStyles.UxThemeOpenThemeData(IntPtr.Zero, element.ClassName); if (theme == IntPtr.Zero) { return(false); } bool retval = VisualStyles.UxThemeIsThemePartDefined(theme, element.Part); VisualStyles.UxThemeCloseThemeData(theme); return(retval); }