Win32.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Runtime.InteropServices;
  3. /// <summary>
  4. /// Wind32API
  5. /// </summary>
  6. internal class Win32
  7. {
  8. [StructLayout(LayoutKind.Sequential)]
  9. public struct Size
  10. {
  11. public Int32 cx;
  12. public Int32 cy;
  13. public Size(Int32 x, Int32 y)
  14. {
  15. cx = x;
  16. cy = y;
  17. }
  18. }
  19. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  20. public struct BLENDFUNCTION
  21. {
  22. public byte BlendOp;
  23. public byte BlendFlags;
  24. public byte SourceConstantAlpha;
  25. public byte AlphaFormat;
  26. }
  27. [StructLayout(LayoutKind.Sequential)]
  28. public struct Point
  29. {
  30. public Int32 x;
  31. public Int32 y;
  32. public Point(Int32 x, Int32 y)
  33. {
  34. this.x = x;
  35. this.y = y;
  36. }
  37. }
  38. public const byte AC_SRC_OVER = 0;
  39. public const Int32 ULW_ALPHA = 2;
  40. public const byte AC_SRC_ALPHA = 1;
  41. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  42. public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
  43. [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
  44. public static extern IntPtr GetDC(IntPtr hWnd);
  45. [DllImport("gdi32.dll", ExactSpelling = true)]
  46. public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObj);
  47. [DllImport("user32.dll", ExactSpelling = true)]
  48. public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
  49. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  50. public static extern int DeleteDC(IntPtr hDC);
  51. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  52. public static extern int DeleteObject(IntPtr hObj);
  53. [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
  54. public static extern int UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pptSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);
  55. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  56. public static extern IntPtr ExtCreateRegion(IntPtr lpXform, uint nCount, IntPtr rgnData);
  57. }