2021-07-04 01:41:15 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Sheng.Winform.Controls.Win32
|
|
|
|
|
|
{
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public class DwmApi
|
|
|
|
|
|
{
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="hWnd"></param>
|
|
|
|
|
|
/// <param name="pBlurBehind"></param>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
|
|
|
|
|
public static extern void DwmEnableBlurBehindWindow(IntPtr hWnd, DWM_BLURBEHIND pBlurBehind);
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="hWnd"></param>
|
|
|
|
|
|
/// <param name="pMargins"></param>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
|
|
|
|
|
public static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, MARGINS pMargins);
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
|
|
|
|
|
public static extern bool DwmIsCompositionEnabled();
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pcrColorization"></param>
|
|
|
|
|
|
/// <param name="pfOpaqueBlend"></param>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
|
|
|
|
|
public static extern void DwmGetColorizationColor(
|
|
|
|
|
|
out int pcrColorization,
|
|
|
|
|
|
[MarshalAs(UnmanagedType.Bool)]out bool pfOpaqueBlend);
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="bEnable"></param>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
|
|
|
|
|
public static extern void DwmEnableComposition(bool bEnable);
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dest"></param>
|
|
|
|
|
|
/// <param name="source"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
|
|
|
|
|
public static extern IntPtr DwmRegisterThumbnail(IntPtr dest, IntPtr source);
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="hThumbnail"></param>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
|
|
|
|
|
public static extern void DwmUnregisterThumbnail(IntPtr hThumbnail);
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="hThumbnail"></param>
|
|
|
|
|
|
/// <param name="props"></param>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
|
|
|
|
|
public static extern void DwmUpdateThumbnailProperties(IntPtr hThumbnail, DWM_THUMBNAIL_PROPERTIES props);
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="hThumbnail"></param>
|
|
|
|
|
|
/// <param name="size"></param>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
|
|
|
|
|
public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size);
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
|
public class DWM_THUMBNAIL_PROPERTIES
|
|
|
|
|
|
{
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public uint dwFlags;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public RECT rcDestination;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public RECT rcSource;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public byte opacity;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
|
public bool fVisible;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
|
public bool fSourceClientAreaOnly;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public const uint DWM_TNP_RECTDESTINATION = 0x00000001;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public const uint DWM_TNP_RECTSOURCE = 0x00000002;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public const uint DWM_TNP_OPACITY = 0x00000004;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public const uint DWM_TNP_VISIBLE = 0x00000008;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010;
|
|
|
|
|
|
}
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
|
public class MARGINS
|
|
|
|
|
|
{
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public int cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="left"></param>
|
|
|
|
|
|
/// <param name="top"></param>
|
|
|
|
|
|
/// <param name="right"></param>
|
|
|
|
|
|
/// <param name="bottom"></param>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public MARGINS(int left, int top, int right, int bottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
cxLeftWidth = left; cyTopHeight = top;
|
|
|
|
|
|
cxRightWidth = right; cyBottomHeight = bottom;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
|
public class DWM_BLURBEHIND
|
|
|
|
|
|
{
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public uint dwFlags;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
|
public bool fEnable;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public IntPtr hRegionBlur;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
|
public bool fTransitionOnMaximized;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public const uint DWM_BB_ENABLE = 0x00000001;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public const uint DWM_BB_BLURREGION = 0x00000002;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public const uint DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004;
|
|
|
|
|
|
}
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
|
public struct RECT
|
|
|
|
|
|
{
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public int left, top, right, bottom;
|
2021-07-29 09:09:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="left"></param>
|
|
|
|
|
|
/// <param name="top"></param>
|
|
|
|
|
|
/// <param name="right"></param>
|
|
|
|
|
|
/// <param name="bottom"></param>
|
2021-07-04 01:41:15 +00:00
|
|
|
|
public RECT(int left, int top, int right, int bottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.left = left; this.top = top; this.right = right; this.bottom = bottom;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|