SafeNativeMethods.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace InABox.WPF
  4. {
  5. public sealed class SafeNativeMethods
  6. {
  7. [Flags]
  8. public enum SetWindowPosFlags : uint
  9. {
  10. SWP_NOACTIVATE = 0x0010,
  11. SWP_NOMOVE = 0x0002,
  12. SWP_NOSIZE = 0x0001
  13. }
  14. public const int WS_EX_NOACTIVATE = 0x08000000;
  15. public const int ULW_ALPHA = 0x00000002;
  16. public const int AC_SRC_OVER = 0x00000000;
  17. public const int AC_SRC_ALPHA = 0x00000001;
  18. public static readonly IntPtr HWND_TOP = new(0);
  19. [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
  20. public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, IntPtr pptDst, IntPtr psize, IntPtr hdcSrc, IntPtr pptSrc,
  21. uint crKey,
  22. [In] ref BLENDFUNCTION pblend, uint dwFlags);
  23. [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
  24. [return: MarshalAs(UnmanagedType.Bool)]
  25. public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags);
  26. public struct BLENDFUNCTION
  27. {
  28. public byte BlendOp;
  29. public byte BlendFlags;
  30. public byte SourceConstantAlpha;
  31. public byte AlphaFormat;
  32. }
  33. }
  34. }