/// <summary> /// Sets attributes to control how visual styles are applied to a specified window. /// </summary> /// <param name="window">The window.</param> /// <param name="attr">The attributes to apply or disable.</param> /// <param name="enable">if set to <c>true</c> enable the attribute, otherwise disable it.</param> public static void SetWindowThemeAttribute(this IWin32Window window, NativeMethods.WindowThemeNonClientAttributes attr, bool enable = true) { NativeMethods.WTA_OPTIONS ops = new NativeMethods.WTA_OPTIONS(); ops.Flags = attr; ops.Mask = enable ? (uint)attr : 0; try { NativeMethods.SetWindowThemeAttribute(window.Handle, NativeMethods.WindowThemeAttributeType.WTA_NONCLIENT, ref ops, Marshal.SizeOf(ops)); } catch (EntryPointNotFoundException) { } catch { throw; } }
/// <summary> /// Sets attributes to control how visual styles are applied to a specified window. /// </summary> /// <param name="window">The window.</param> /// <param name="attr">The attributes to apply or disable.</param> /// <param name="enable">if set to <c>true</c> enable the attribute, otherwise disable it.</param> public static void SetWindowThemeAttribute(this IWin32Window window, NativeMethods.WindowThemeNonClientAttributes attr, bool enable = true) { try { NativeMethods.SetWindowThemeAttribute(window, attr, enable ? (int)attr : 0); } catch (EntryPointNotFoundException) { } }