public static void HideIconAndText(Form form, bool hide_icon, bool hide_text) { if (!CanAero) { return; } if (!hide_icon && !hide_text) { return; } WTA_OPTIONS options = new WTA_OPTIONS(); if (hide_icon) { options.dwFlags = WTNCA.NODRAWICON; if (hide_text) { options.dwFlags |= WTNCA.NODRAWCAPTION; } } else { options.dwFlags = WTNCA.NODRAWCAPTION; } options.dwMask = WTNCA.VALIDBITS; SetWindowThemeAttribute(form.Handle, WINDOWTHEMEATTRIBUTETYPE.WTA_NONCLIENT, ref options, (uint)Marshal.SizeOf(typeof(WTA_OPTIONS))); }
public static void SetWindowThemeAttribute(System.Windows.Window window, bool showCaption, bool showIcon) { bool isGlassEnabled = IsCompositionEnabled; if (!isGlassEnabled) { return; } IntPtr hwnd = new WindowInteropHelper(window).Handle; var options = new WTA_OPTIONS { dwMask = (WTNCA.NODRAWCAPTION | WTNCA.NODRAWICON) }; if (!showCaption) { options.dwFlags |= WTNCA.NODRAWCAPTION; } if (!showIcon) { options.dwFlags |= WTNCA.NODRAWICON; } SetWindowThemeAttribute(hwnd, WINDOWTHEMEATTRIBUTETYPE.WTA_NONCLIENT, ref options, WTA_OPTIONS.Size); }
public static int SetWindowThemeAttribute(IWin32Window wnd, WindowThemeNonClientAttributes ncAttrs, int ncAttrMasks = int.MaxValue) { var opt = new WTA_OPTIONS { Flags = ncAttrs, Mask = ncAttrMasks == int.MaxValue ? (int)ncAttrs : ncAttrMasks }; return(SetWindowThemeAttribute(wnd?.Handle ?? IntPtr.Zero, WindowThemeAttributeType.NonClient, ref opt, Marshal.SizeOf(opt))); }
public static HRESULT SetWindowThemeNonClientAttributes(HWND hwnd, uint dwMask, uint dwAttributes) { var wta = new WTA_OPTIONS { dwFlags = dwAttributes, dwMask = dwMask, }; return(SetWindowThemeAttribute(hwnd, WTA_NONCLIENT, (void *)&(wta), (uint)sizeof(WTA_OPTIONS))); }
/// <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, WindowThemeNonClientAttributes attr, bool enable = true) { WTA_OPTIONS ops = new WTA_OPTIONS(); ops.Flags = attr; ops.Mask = enable ? (uint)attr : 0; try { SetWindowThemeAttribute(window.Handle, WindowThemeAttributeType.WTA_NONCLIENT, ref ops, Marshal.SizeOf(ops)); } catch (EntryPointNotFoundException) { } catch { throw; } }
/// <summary>Calls <see cref="Uxtheme.SetWindowThemeAttribute" /> to set various attributes on the window.</summary> /// <param name="attributes">Attributes to set on the window.</param> private void SetWindowThemeAttributes(WTNCA attributes) { WTA_OPTIONS options = new WTA_OPTIONS { dwFlags = attributes, dwMask = WTNCA.VALIDBITS }; // The SetWindowThemeAttribute API call takes care of everything Uxtheme.SetWindowThemeAttribute(Handle, WINDOWTHEMEATTRIBUTETYPE.WTA_NONCLIENT, ref options, (uint)Marshal.SizeOf(typeof(WTA_OPTIONS))); }
/// <summary> /// Sets attributes to control how visual styles are applied to a specified window. /// </summary> /// <param name="hWnd">Handle to a window to apply changes to.</param> /// <param name="ncAttrs">A combination of flags that modify window visual style attributes.</param> /// <param name="activate">if set to <c>true</c> add the flag to the window attributes, otherwise remove the flag.</param> public static void SetWindowThemeAttribute(HandleRef hWnd, WindowThemeNonClientAttributes ncAttrs, bool activate = true) { var opt = new WTA_OPTIONS { Flags = ncAttrs, Mask = activate ? (int)ncAttrs : 0 }; var ret = SetWindowThemeAttribute(hWnd, WindowThemeAttributeType.NonClient, ref opt, Marshal.SizeOf(opt)); if (ret != 0) { throw new Win32Exception(ret); } }
public static void HideTitleInfo(Window window, WTNCA attributes) { if (!hide_done) { hide_done = true; if (CanAero) { WTA_OPTIONS options = new WTA_OPTIONS(); options.dwFlags = attributes; options.dwMask = WTNCA.VALIDBITS; SetWindowThemeAttribute(new WindowInteropHelper(window).Handle, WINDOWTHEMEATTRIBUTETYPE.WTA_NONCLIENT, ref options, (uint)Marshal.SizeOf(typeof(WTA_OPTIONS))); } } }
private static void HideChromeElementCore(Window window, bool hideIcon, bool hideCaption) { var wta = new WTA_OPTIONS(); if (hideCaption) { wta.Flags |= WTNCA_NODRAWCAPTION; wta.Mask |= WTNCA_NODRAWCAPTION; } if (hideIcon) { wta.Flags |= WTNCA_NODRAWICON; wta.Mask |= WTNCA_NODRAWICON; } var hwnd = GetWindowHwnd(window); SetWindowThemeAttribute(hwnd, WindowThemeAttributeType.WTA_NONCLIENT, ref wta, (uint)Marshal.SizeOf(typeof(WTA_OPTIONS))); }
internal static extern void SetWindowThemeAttribute(IntPtr hwnd, WINDOWTHEMEATTRIBUTETYPE eAttribute, ref WTA_OPTIONS pvAttribute, int cbAttribute);
public static extern int SetWindowThemeAttribute(IntPtr hwnd, WINDOWTHEMEATTRIBUTETYPE eAttribute, ref WTA_OPTIONS pvAttribute, uint cbAttribute);
public static void SetWindowThemeAttribute(System.Windows.Window window, bool showCaption, bool showIcon) { bool isGlassEnabled = IsCompositionEnabled; if (!isGlassEnabled) return; IntPtr hwnd = new WindowInteropHelper(window).Handle; var options = new WTA_OPTIONS { dwMask = (WTNCA.NODRAWCAPTION | WTNCA.NODRAWICON) }; if (!showCaption) { options.dwFlags |= WTNCA.NODRAWCAPTION; } if (!showIcon) { options.dwFlags |= WTNCA.NODRAWICON; } SetWindowThemeAttribute(hwnd, WINDOWTHEMEATTRIBUTETYPE.WTA_NONCLIENT, ref options, WTA_OPTIONS.Size); }
public static extern int SetWindowThemeAttribute(IntPtr hWnd, WindowThemeAttributeType wtype, ref WTA_OPTIONS attributes, uint size);
private static void HideChromeElementCore(Window window, bool hideIcon, bool hideCaption) { var wta = new WTA_OPTIONS(); if (hideCaption) { wta.Flags |= WTNCA_NODRAWCAPTION; wta.Mask |= WTNCA_NODRAWCAPTION; } if (hideIcon) { wta.Flags |= WTNCA_NODRAWICON; wta.Mask |= WTNCA_NODRAWICON; } var hwnd = GetWindowHwnd(window); SetWindowThemeAttribute(hwnd, WindowThemeAttributeType.WTA_NONCLIENT, ref wta, (uint)Marshal.SizeOf(typeof(WTA_OPTIONS))); }
public static extern void SetWindowThemeAttribute(IntPtr hWnd, WindowThemeAttributeType wtype, ref WTA_OPTIONS attributes, int size);
private static extern int SetWindowThemeAttribute(IntPtr hWnd, WINDOWTHEMEATTRIBUTETYPE wtype, ref WTA_OPTIONS attributes, uint size);
public static extern int SetWindowThemeAttribute(HandleRef hWnd, WindowThemeAttributeType wtype, ref WTA_OPTIONS attributes, int size);
public static extern void SetWindowThemeAttribute([In] IntPtr hwnd, [In] uint eAttribute, [In] ref WTA_OPTIONS pvAttribute, [In] uint cbAttribute);
/// <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, WindowThemeNonClientAttributes attr, bool enable = true) { WTA_OPTIONS ops = new WTA_OPTIONS(); ops.Flags = attr; ops.Mask = enable ? (uint)attr : 0; try { SetWindowThemeAttribute(window.Handle, WindowThemeAttributeType.WTA_NONCLIENT, ref ops, Marshal.SizeOf(ops)); } catch (EntryPointNotFoundException) { } catch { throw; } }
private static bool _SetWindowThemeAttribute(Window window, bool showCaption, bool showIcon) { bool isGlassEnabled; Assert.IsNotNull(window); Assert.IsTrue(window.CheckAccess()); // This only is expected to work if Aero glass is enabled. try { isGlassEnabled = NativeMethods.DwmIsCompositionEnabled(); } catch (DllNotFoundException) { // Not an error. Just not on Vista so we're not going to get glass. return false; } IntPtr hwnd = new WindowInteropHelper(window).Handle; if (IntPtr.Zero == hwnd) { throw new InvalidOperationException("Window must be shown before we can modify attributes."); } var options = new WTA_OPTIONS { dwMask = (WTNCA.NODRAWCAPTION | WTNCA.NODRAWICON) }; if (isGlassEnabled) { if (!showCaption) { options.dwFlags |= WTNCA.NODRAWCAPTION; } if (!showIcon) { options.dwFlags |= WTNCA.NODRAWICON; } } NativeMethods.SetWindowThemeAttribute(hwnd, WINDOWTHEMEATTRIBUTETYPE.WTA_NONCLIENT, ref options, WTA_OPTIONS.Size); bool addHook = !_attributedWindows.ContainsKey(hwnd); if (addHook) { HwndSourceHook hook = delegate(IntPtr unusedHwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (WM.DWMCOMPOSITIONCHANGED == (WM)msg) { _SetWindowThemeAttribute(window, showCaption, showIcon); handled = false; } return IntPtr.Zero; }; _attributedWindows.Add(hwnd, hook); HwndSource.FromHwnd(hwnd).AddHook(hook); window.Closing += _OnAttributedWindowClosing; } return isGlassEnabled; }
internal static extern void SetWindowThemeAttribute(IntPtr hwnd, WINDOWTHEMEATTRIBUTETYPE eAttribute, ref WTA_OPTIONS pvAttribute, int cbAttribute);
private static bool _SetWindowThemeAttribute(Window window, bool showCaption, bool showIcon) { bool isGlassEnabled; Assert.IsNotNull(window); Assert.IsTrue(window.CheckAccess()); // This only is expected to work if Aero glass is enabled. try { isGlassEnabled = NativeMethods.DwmIsCompositionEnabled(); } catch (DllNotFoundException) { // Not an error. Just not on Vista so we're not going to get glass. return(false); } IntPtr hwnd = new WindowInteropHelper(window).Handle; if (IntPtr.Zero == hwnd) { throw new InvalidOperationException("Window must be shown before we can modify attributes."); } var options = new WTA_OPTIONS { dwMask = (WTNCA.NODRAWCAPTION | WTNCA.NODRAWICON) }; if (isGlassEnabled) { if (!showCaption) { options.dwFlags |= WTNCA.NODRAWCAPTION; } if (!showIcon) { options.dwFlags |= WTNCA.NODRAWICON; } } NativeMethods.SetWindowThemeAttribute(hwnd, WINDOWTHEMEATTRIBUTETYPE.WTA_NONCLIENT, ref options, WTA_OPTIONS.Size); bool addHook = !_attributedWindows.ContainsKey(hwnd); if (addHook) { HwndSourceHook hook = delegate(IntPtr unusedHwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (WM.DWMCOMPOSITIONCHANGED == (WM)msg) { _SetWindowThemeAttribute(window, showCaption, showIcon); handled = false; } return(IntPtr.Zero); }; _attributedWindows.Add(hwnd, hook); HwndSource.FromHwnd(hwnd).AddHook(hook); window.Closing += _OnAttributedWindowClosing; } return(isGlassEnabled); }
internal static extern void SetWindowThemeAttribute(IntPtr hWnd, WindowThemeAttributeType wtype, ref WTA_OPTIONS attributes, int size);
private static extern int SetWindowThemeAttribute(IntPtr hWnd, WindowThemeAttributeType wtype, ref WTA_OPTIONS attributes, int size);
public static extern void SetWindowThemeAttribute([In] IntPtr hwnd, [In] WINDOWTHEMEATTRIBUTETYPE eAttribute, [In] ref WTA_OPTIONS pvAttribute, [In] uint cbAttribute);