Пример #1
0
 /// <summary>
 /// Sets the specified window attribute through the Desktop Window Manager (DWM).
 /// </summary>
 /// <param name="window">The window.</param>
 /// <param name="attribute">The attribute.</param>
 /// <param name="value">The value.</param>
 public static void SetWindowAttribute <T>(this IWin32Window window, SetWindowAttr attribute, T value) where T : struct
 {
     if (window == null)
     {
         throw new ArgumentNullException(nameof(window));
     }
     using (var ptr = SafeCoTaskMemHandle.AllocCoTaskMemStruct <T>(value))
         DwmSetWindowAttribute(window.Handle, (DWMWINDOWATTRIBUTE)attribute, (IntPtr)ptr, ptr.Size);
 }
 /// <summary>
 /// Sets the specified window attribute through the Desktop Window Manager (DWM).
 /// </summary>
 /// <param name="window">The window.</param>
 /// <param name="attribute">The attribute.</param>
 /// <param name="value">The value.</param>
 public static void SetWindowAttribute(this IWin32Window window, SetWindowAttr attribute, object value)
 {
     if (window == null)
     {
         throw new ArgumentNullException(nameof(window));
     }
     if (value == null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     using (var ptr = new System.Runtime.InteropServices.SafeHGlobalHandle(value))
         NativeMethods.DwmSetWindowAttribute(window.Handle, (NativeMethods.DWMWINDOWATTRIBUTE)attribute, ptr, ptr.Size);
 }