| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- namespace Azylee.WinformSkin.APIUtils
- {
- public class FormStyleAPI
- {
- [StructLayout(LayoutKind.Sequential)]
- public struct Size
- {
- public Int32 cx;
- public Int32 cy;
- public Size(Int32 x, Int32 y)
- {
- cx = x;
- cy = y;
- }
- }
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- public struct BLENDFUNCTION
- {
- public byte BlendOp;
- public byte BlendFlags;
- public byte SourceConstantAlpha;
- public byte AlphaFormat;
- }
- [StructLayout(LayoutKind.Sequential)]
- public struct Point
- {
- public Int32 x;
- public Int32 y;
- public Point(Int32 x, Int32 y)
- {
- this.x = x;
- this.y = y;
- }
- }
- public const byte AC_SRC_OVER = 0;
- public const Int32 ULW_ALPHA = 2;
- public const byte AC_SRC_ALPHA = 1;
- /// <summary>
- /// 从左到右显示
- /// </summary>
- public const Int32 AW_HOR_POSITIVE = 0x00000001;
- /// <summary>
- /// 从右到左显示
- /// </summary>
- public const Int32 AW_HOR_NEGATIVE = 0x00000002;
- /// <summary>
- /// 从上到下显示
- /// </summary>
- public const Int32 AW_VER_POSITIVE = 0x00000004;
- /// <summary>
- /// 从下到上显示
- /// </summary>
- public const Int32 AW_VER_NEGATIVE = 0x00000008;
- /// <summary>
- /// 若使用了AW_HIDE标志,则使窗口向内重叠,即收缩窗口;否则使窗口向外扩展,即展开窗口
- /// </summary>
- public const Int32 AW_CENTER = 0x00000010;
- /// <summary>
- /// 隐藏窗口,缺省则显示窗口
- /// </summary>
- public const Int32 AW_HIDE = 0x00010000;
- /// <summary>
- /// 激活窗口。在使用了AW_HIDE标志后不能使用这个标志
- /// </summary>
- public const Int32 AW_ACTIVATE = 0x00020000;
- /// <summary>
- /// 使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略
- /// </summary>
- public const Int32 AW_SLIDE = 0x00040000;
- /// <summary>
- /// 透明度从高到低
- /// </summary>
- public const Int32 AW_BLEND = 0x00080000;
- #region MyRegion
- public const int WM_ERASEBKGND = 0x0014;
- public const int WM_LBUTTONDOWN = 0x0201;
- public const int WM_LBUTTONUP = 0x0202;
- public const int WM_LBUTTONDBLCLK = 0x0203;
- public const int WM_WINDOWPOSCHANGING = 0x46;
- public const int WM_PAINT = 0xF;
- public const int WM_CREATE = 0x0001;
- public const int WM_ACTIVATE = 0x0006;
- public const int WM_NCCREATE = 0x0081;
- public const int WM_NCCALCSIZE = 0x0083;
- public const int WM_NCPAINT = 0x0085;
- public const int WM_NCACTIVATE = 0x0086;
- public const int WM_NCLBUTTONDOWN = 0x00A1;
- public const int WM_NCLBUTTONUP = 0x00A2;
- public const int WM_NCLBUTTONDBLCLK = 0x00A3;
- public const int WM_NCMOUSEMOVE = 0x00A0;
- public const int WM_NCHITTEST = 0x0084;
- public const int HTLEFT = 10;
- public const int HTRIGHT = 11;
- public const int HTTOP = 12;
- public const int HTTOPLEFT = 13;
- public const int HTTOPRIGHT = 14;
- public const int HTBOTTOM = 15;
- public const int HTBOTTOMLEFT = 0x10;
- public const int HTBOTTOMRIGHT = 17;
- public const int HTCAPTION = 2;
- public const int HTCLIENT = 1;
- public const int WM_FALSE = 0;
- public const int WM_TRUE = 1;
- #endregion
- /// <summary>
- /// 执行动画
- /// </summary>
- /// <param name="whnd">控件句柄</param>
- /// <param name="dwtime">动画时间</param>
- /// <param name="dwflag">动画组合名称</param>
- /// <returns>bool值,动画是否成功</returns>
- [DllImport("user32")]
- public static extern bool AnimateWindow(IntPtr whnd, int dwtime, int dwflag);
- [DllImport("user32")]
- public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
- [DllImport("gdi32.dll")]
- public static extern int CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3);
- [DllImport("user32.dll")]
- public static extern int SetWindowRgn(IntPtr hwnd, int hRgn, Boolean bRedraw);
- [DllImport("user32", EntryPoint = "GetWindowLong")]
- public static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
- [DllImport("user32", EntryPoint = "SetWindowLong")]
- public static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);
- [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
- public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
- [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
- public static extern IntPtr GetDC(IntPtr hWnd);
- [DllImport("gdi32.dll", ExactSpelling = true)]
- public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObj);
- [DllImport("user32.dll", ExactSpelling = true)]
- public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
- [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
- public static extern int DeleteDC(IntPtr hDC);
- [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
- public static extern int DeleteObject(IntPtr hObj);
- [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
- 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);
- [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
- public static extern IntPtr ExtCreateRegion(IntPtr lpXform, uint nCount, IntPtr rgnData);
- [DllImport("user32.dll")]
- public static extern bool ReleaseCapture();
- [DllImport("user32.dll")]
- public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
- }
- }
|