Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Collections;
- using System.Diagnostics;
- using System.Drawing.Drawing2D;
- using System.Runtime.InteropServices;
- namespace ZoSoft.Themes
- {
- public partial class Win8Form : Form
- {
- //Variable
- private const int WM_NCHITTEST = 0x84;
- private const int HTCLIENT = 0x1;
- private const int HTCAPTION = 0x2;
- public const int WMNCLBUTTONDOWN = 0xA1;
- [DllImportAttribute("user32.dll")]
- public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
- [DllImportAttribute("user32.dll")]
- public static extern bool ReleaseCapture();
- [DllImport("user32.dll")]
- static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
- private const int _shadowsize = 1;
- private Color _backColor = Color.FromArgb(118, 187, 236);
- private Dwm.MARGINS dwmMargins;
- private bool _marginOk;
- private bool _aeroEnabled;
- private const int BorderWidth = 6;
- private ResizeDirection _resizeDir;
- private const int WM_NCLBUTTONDOWN = 161;
- private const int HTBORDER = 18;
- private const int HTBOTTOM = 15;
- private const int HTBOTTOMLEFT = 16;
- private const int HTBOTTOMRIGHT = 17;
- private const int HTLEFT = 10;
- private const int HTRIGHT = 11;
- private const int HTTOP = 12;
- private const int HTTOPLEFT = 13;
- private const int HTTOPRIGHT = 14;
- private Label close = new Label();
- private Label min = new Label();
- private Label max = new Label();
- //Enum
- public enum ResizeDirection
- {
- None = 0,
- Left = 1,
- TopLeft = 2,
- Top = 4,
- TopRight = 8,
- Right = 16,
- BottomRight = 32,
- Bottom = 64,
- BottomLeft = 128
- }
- //Properties
- public override Color BackColor
- {
- get
- {
- return _backColor;
- }
- set
- {
- _backColor = value;
- Invalidate();
- }
- }
- public bool AeroEnabled
- {
- get
- {
- return this._aeroEnabled;
- }
- set { this._aeroEnabled = value; Invalidate(); }
- }
- //Constructor
- public Win8Form()
- {
- SetStyle(ControlStyles.Selectable | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
- StartPosition = FormStartPosition.Manual;
- FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- base.BackColor = this.BackColor;
- base.Opacity = this.Opacity = 0.90F;
- this._aeroEnabled = false;
- this._resizeDir = ResizeDirection.None;
- this.DoubleBuffered = true;
- this.MinimumSize = new Size(100, 100);
- this.close.Text = "X";
- this.min.Text = "-";
- this.max.Text = "□";
- this.close.AutoSize = false;
- this.min.AutoSize = false;
- this.max.AutoSize = false;
- this.min.BackColor = System.Drawing.Color.Transparent;
- this.min.Font = new System.Drawing.Font("Lucida Console", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.min.Size = new System.Drawing.Size(25, 16);
- this.min.TabIndex = 1;
- this.min.Text = "-";
- this.min.ForeColor = Color.Yellow;
- this.min.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- this.min.MouseHover += new System.EventHandler(ControlMouseOver);
- this.min.MouseLeave += new System.EventHandler(ControlMouseLeave);
- this.min.MouseClick += new System.Windows.Forms.MouseEventHandler(MinClick);
- this.max.BackColor = System.Drawing.Color.Transparent;
- this.max.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.max.Size = new System.Drawing.Size(24, 20);
- this.max.TabIndex = 2;
- this.max.ForeColor = Color.GreenYellow;
- this.max.Text = "□";
- this.max.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- this.max.MouseHover += new System.EventHandler(ControlMouseOver);
- this.max.MouseLeave += new System.EventHandler(ControlMouseLeave);
- this.max.MouseClick += new System.Windows.Forms.MouseEventHandler(MaxClick);
- this.close.Size = new System.Drawing.Size(49, 19);
- this.close.TabIndex = 3;
- this.close.Text = "X";
- this.close.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- this.close.BackColor = System.Drawing.Color.Transparent;
- this.close.ForeColor = Color.Red;
- this.close.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.close.MouseHover += new System.EventHandler(ControlMouseOver);
- this.close.MouseLeave += new System.EventHandler(ControlMouseLeave);
- this.close.MouseClick += new System.Windows.Forms.MouseEventHandler(CloseClick);
- }
- //Override
- protected override void WndProc(ref Message m)
- {
- IntPtr result = default(IntPtr);
- int WM_NCCALCSIZE = 131;
- int WM_NCHITTEST = 132;
- if (Dwm.DwmDefWindowProc(m.HWnd, m.Msg, m.WParam, m.LParam, ref result) == 1)
- {
- m.Result = result;
- }
- else if ((m.Msg != WM_NCCALCSIZE || (int)m.WParam != 1 ? false : true))
- {
- WinApi.NCCALCSIZE_PARAMS nccsp = (WinApi.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(WinApi.NCCALCSIZE_PARAMS));
- nccsp.rect0.Top = checked(nccsp.rect0.Top + 0);
- nccsp.rect0.Bottom = checked(nccsp.rect0.Bottom + 0);
- nccsp.rect0.Left = checked(nccsp.rect0.Left + 0);
- nccsp.rect0.Right = checked(nccsp.rect0.Right + 0);
- if (!this._marginOk)
- {
- this.dwmMargins.cyTopHeight = 0;
- this.dwmMargins.cxLeftWidth = 0;
- this.dwmMargins.cyBottomHeight = 3;
- this.dwmMargins.cxRightWidth = 0;
- this._marginOk = true;
- }
- Marshal.StructureToPtr(nccsp, m.LParam, false);
- m.Result = IntPtr.Zero;
- }
- else if ((m.Msg != WM_NCHITTEST || (int)m.Result != 0 ? true : false))
- {
- base.WndProc(ref m);
- }
- else
- {
- m.Result = this.HitTestNCA(m.HWnd, m.WParam, m.LParam);
- }
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- Graphics g = e.Graphics;
- g.SmoothingMode = SmoothingMode.HighQuality;
- int cPosition = Width - 110;
- g.DrawRectangle(new Pen(new SolidBrush(Color.Black), 1f), new Rectangle(1, 1, Width - 3, Height - 6));
- //Form Icon
- g.DrawIcon(base.Icon, new Rectangle(6, 6, 32, 32));
- //Draw Form Caption Text
- int captionposition = (base.FontHeight / 2);
- g.DrawString(base.Text, base.Font, new SolidBrush(base.ForeColor), 38f, captionposition);
- //Controls
- // Create pen.
- Pen blackPen = new Pen(Color.Black, 1);
- // Create array of rectangles.
- Rectangle[] rects =
- {
- new Rectangle(cPosition, 6, 25, 25),
- new Rectangle(cPosition+25, 6, 25, 25),
- new Rectangle(cPosition+25+25, 6, 50, 25)
- };
- // Draw rectangles to screen.
- e.Graphics.DrawRectangles(blackPen, rects);
- //Draw Control Text
- this.Controls.Add(close);
- this.Controls.Add(max);
- this.Controls.Add(min);
- //Small Setting for position
- this.close.Location = new Point(cPosition+25+25,8);
- this.max.Location = new Point(cPosition + 26, 5);
- this.min.Location = new Point(cPosition+1, 14);
- base.OnPaint(e);
- }
- protected override void OnActivated(EventArgs e)
- {
- Dwm.DwmExtendFrameIntoClientArea(this.Handle, ref this.dwmMargins);
- base.OnActivated(e);
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- //ReleaseCapture();
- //SendMessage(Handle, WMNCLBUTTONDOWN, HTCAPTION, 0);
- if ((checked(this.Width - 6) <= e.Location.X || e.Location.X <= 6 || e.Location.Y <= 6 ? false : true))
- {
- this.MoveControl(this.Handle);
- }
- else if (this.WindowState != FormWindowState.Maximized)
- {
- this.ResizeForm(this.resizeDir);
- }
- }
- base.OnMouseDown(e);
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- Point location = e.Location;
- Point point = e.Location;
- if (!(location.X < 6 & point.Y < 6))
- {
- point = e.Location;
- location = e.Location;
- if (point.X < 6 & location.Y > checked(this.Height - 6))
- {
- this.resizeDir = ResizeDirection.BottomLeft;
- }
- else if (e.Location.X > checked(this.Width - 6) & e.Location.Y > checked(this.Height - 6))
- {
- this.resizeDir = ResizeDirection.BottomRight;
- }
- else if (e.Location.X > checked(this.Width - 6) & e.Location.Y < 6)
- {
- this.resizeDir = ResizeDirection.TopRight;
- }
- else if (e.Location.X < 6)
- {
- this.resizeDir = ResizeDirection.Left;
- }
- else if (e.Location.X > checked(this.Width - 6))
- {
- this.resizeDir = ResizeDirection.Right;
- }
- else if (e.Location.Y < 6)
- {
- this.resizeDir = ResizeDirection.Top;
- }
- else if (e.Location.Y <= checked(this.Height - 6))
- {
- this.resizeDir = ResizeDirection.None;
- }
- else
- {
- this.resizeDir = ResizeDirection.Bottom;
- }
- }
- else
- {
- this.resizeDir = ResizeDirection.TopLeft;
- }
- base.OnMouseMove(e);
- }
- protected override void OnResize(EventArgs e)
- {
- Refresh();
- base.OnResize(e);
- }
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // Win8Form
- //
- this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(118)))), ((int)(((byte)(187)))), ((int)(((byte)(236)))));
- this.ClientSize = new System.Drawing.Size(280, 285);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- this.Name = "Win8Form";
- this.ResumeLayout(false);
- }
- //Methods
- private void ControlMouseOver(object sender, EventArgs e)
- {
- Cursor = Cursors.Hand;
- }
- private void ControlMouseLeave(object sender, EventArgs e)
- {
- Cursor = Cursors.Default;
- }
- private void CloseClick(object sender, MouseEventArgs e)
- {
- base.Close();
- }
- private void MaxClick(object sender, MouseEventArgs e)
- {
- if (WindowState == FormWindowState.Maximized)
- {
- WindowState = FormWindowState.Normal;
- }
- else
- {
- WindowState = FormWindowState.Maximized;
- //ShowWindow(Handle, 3);
- }
- }
- private void MinClick(object sender, MouseEventArgs e)
- {
- ShowWindow(Handle, 6);
- }
- private IntPtr HitTestNCA(IntPtr hwnd, IntPtr wparam, IntPtr lparam)
- {
- IntPtr HitTestNCA;
- IntPtr intPtr;
- int HTCLIENT = 1;
- int HTCAPTION = 2;
- int HTMINBUTTON = 8;
- int HTMAXBUTTON = 9;
- int HTLEFT = 10;
- int HTRIGHT = 11;
- int HTTOP = 12;
- int HTTOPLEFT = 13;
- int HTTOPRIGHT = 14;
- int HTBOTTOM = 15;
- int HTBOTTOMLEFT = 16;
- int HTBOTTOMRIGHT = 17;
- Point p = new Point(LoWord((int)lparam), HiWord((int)lparam));
- Rectangle rectangle = new Rectangle(0, 0, this.dwmMargins.cxLeftWidth, this.dwmMargins.cxLeftWidth);
- if (!this.RectangleToScreen(rectangle).Contains(p))
- {
- rectangle = new Rectangle(checked(this.Width - this.dwmMargins.cxRightWidth), 0, this.dwmMargins.cxRightWidth, this.dwmMargins.cxRightWidth);
- if (!this.RectangleToScreen(rectangle).Contains(p))
- {
- rectangle = new Rectangle(0, checked(this.Height - this.dwmMargins.cyBottomHeight), this.dwmMargins.cxLeftWidth, this.dwmMargins.cyBottomHeight);
- if (!this.RectangleToScreen(rectangle).Contains(p))
- {
- rectangle = new Rectangle(checked(this.Width - this.dwmMargins.cxRightWidth), checked(this.Height - this.dwmMargins.cyBottomHeight), this.dwmMargins.cxRightWidth, this.dwmMargins.cyBottomHeight);
- if (!this.RectangleToScreen(rectangle).Contains(p))
- {
- rectangle = new Rectangle(0, 0, this.Width, this.dwmMargins.cxLeftWidth);
- if (!this.RectangleToScreen(rectangle).Contains(p))
- {
- rectangle = new Rectangle(0, this.dwmMargins.cxLeftWidth, this.Width, checked(this.dwmMargins.cyTopHeight - this.dwmMargins.cxLeftWidth));
- if (!this.RectangleToScreen(rectangle).Contains(p))
- {
- rectangle = new Rectangle(0, 0, this.dwmMargins.cxLeftWidth, this.Height);
- if (!this.RectangleToScreen(rectangle).Contains(p))
- {
- rectangle = new Rectangle(checked(this.Width - this.dwmMargins.cxRightWidth), 0, this.dwmMargins.cxRightWidth, this.Height);
- if (!this.RectangleToScreen(rectangle).Contains(p))
- {
- rectangle = new Rectangle(0, checked(this.Height - this.dwmMargins.cyBottomHeight), this.Width, this.dwmMargins.cyBottomHeight);
- if (!this.RectangleToScreen(rectangle).Contains(p))
- {
- intPtr = new IntPtr(HTCLIENT);
- HitTestNCA = intPtr;
- }
- else
- {
- intPtr = new IntPtr(HTBOTTOM);
- HitTestNCA = intPtr;
- }
- }
- else
- {
- intPtr = new IntPtr(HTRIGHT);
- HitTestNCA = intPtr;
- }
- }
- else
- {
- intPtr = new IntPtr(HTLEFT);
- HitTestNCA = intPtr;
- }
- }
- else
- {
- intPtr = new IntPtr(HTCAPTION);
- HitTestNCA = intPtr;
- }
- }
- else
- {
- intPtr = new IntPtr(HTTOP);
- HitTestNCA = intPtr;
- }
- }
- else
- {
- intPtr = new IntPtr(HTBOTTOMRIGHT);
- HitTestNCA = intPtr;
- }
- }
- else
- {
- intPtr = new IntPtr(HTBOTTOMLEFT);
- HitTestNCA = intPtr;
- }
- }
- else
- {
- intPtr = new IntPtr(HTTOPRIGHT);
- HitTestNCA = intPtr;
- }
- }
- else
- {
- intPtr = new IntPtr(HTTOPLEFT);
- HitTestNCA = intPtr;
- }
- return HitTestNCA;
- }
- public static int HiWord(int dwValue)
- {
- return dwValue >> 16 & 65535;
- }
- public static int LoWord(int dwValue)
- {
- return dwValue & 65535;
- }
- private void ResizeForm(ResizeDirection direction)
- {
- int dir = -1;
- ResizeDirection resizeDirection = direction;
- if (resizeDirection == ResizeDirection.Left)
- {
- dir = 10;
- }
- else if (resizeDirection == ResizeDirection.TopLeft)
- {
- dir = 13;
- }
- else if (resizeDirection == ResizeDirection.Top)
- {
- dir = 12;
- }
- else if (resizeDirection == ResizeDirection.TopRight)
- {
- dir = 14;
- }
- else if (resizeDirection == ResizeDirection.Right)
- {
- dir = 11;
- }
- else if (resizeDirection == ResizeDirection.BottomRight)
- {
- dir = 17;
- }
- else if (resizeDirection == ResizeDirection.Bottom)
- {
- dir = 15;
- }
- else if (resizeDirection == ResizeDirection.BottomLeft)
- {
- dir = 16;
- }
- if (dir != -1)
- {
- ReleaseCapture();
- SendMessage(this.Handle, 161, dir, 0);
- }
- }
- private void MoveControl(IntPtr hWnd)
- {
- ReleaseCapture();
- SendMessage(hWnd, 161, 2, 0);
- }
- private ResizeDirection resizeDir
- {
- get
- {
- return this._resizeDir;
- }
- set
- {
- this._resizeDir = value;
- ResizeDirection resizeDirection = value;
- if (resizeDirection == ResizeDirection.Left)
- {
- this.Cursor = Cursors.SizeWE;
- }
- else if (resizeDirection == ResizeDirection.Right)
- {
- this.Cursor = Cursors.SizeWE;
- }
- else if (resizeDirection == ResizeDirection.Top)
- {
- this.Cursor = Cursors.SizeNS;
- }
- else if (resizeDirection == ResizeDirection.Bottom)
- {
- this.Cursor = Cursors.SizeNS;
- }
- else if (resizeDirection == ResizeDirection.BottomLeft)
- {
- this.Cursor = Cursors.SizeNESW;
- }
- else if (resizeDirection == ResizeDirection.TopRight)
- {
- this.Cursor = Cursors.SizeNESW;
- }
- else if (resizeDirection == ResizeDirection.BottomRight)
- {
- this.Cursor = Cursors.SizeNWSE;
- }
- else if (resizeDirection != ResizeDirection.TopLeft)
- {
- this.Cursor = Cursors.Default;
- }
- else
- {
- this.Cursor = Cursors.SizeNWSE;
- }
- }
- }
- }
- #region "Useful API"
- //Credit http://www.codeproject.com/Articles/138661/Metro-UI-Zune-like-Interface-form
- public class Dwm
- {
- public const int DWM_BB_BLURREGION = 2;
- public const int DWM_BB_ENABLE = 1;
- public const int DWM_BB_TRANSITIONONMAXIMIZED = 4;
- public const string DWM_COMPOSED_EVENT_BASE_NAME = "DwmComposedEvent_";
- public const string DWM_COMPOSED_EVENT_NAME_FORMAT = "%s%d";
- public const int DWM_COMPOSED_EVENT_NAME_MAX_LENGTH = 64;
- public const int DWM_FRAME_DURATION_DEFAULT = -1;
- public const int DWM_TNP_OPACITY = 4;
- public const int DWM_TNP_RECTDESTINATION = 1;
- public const int DWM_TNP_RECTSOURCE = 2;
- public const int DWM_TNP_SOURCECLIENTAREAONLY = 16;
- public const int DWM_TNP_VISIBLE = 8;
- public readonly static bool DwmApiAvailable;
- public const int WM_DWMCOMPOSITIONCHANGED = 798;
- /// <summary>
- /// Do Not Draw The Caption (Text)
- /// </summary>
- public static uint WTNCA_NODRAWCAPTION;
- public static uint WTNCA_NODRAWICON;
- /// <summary>
- /// Do Not Show the System Menu
- /// </summary>
- public static uint WTNCA_NOSYSMENU;
- public static uint WTNCA_NOMIRRORHELP;
- static Dwm()
- {
- Dwm.DwmApiAvailable = Environment.OSVersion.Version.Major >= 6;
- Dwm.WTNCA_NODRAWCAPTION = 1;
- Dwm.WTNCA_NODRAWICON = 2;
- Dwm.WTNCA_NOSYSMENU = 4;
- Dwm.WTNCA_NOMIRRORHELP = 8;
- }
- [DebuggerNonUserCode]
- public Dwm()
- {
- }
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmDefWindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref IntPtr result);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmEnableComposition(int fEnable);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmEnableMMCSS(int fEnableMMCSS);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmExtendFrameIntoClientArea(IntPtr hdc, ref Dwm.MARGINS marInset);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmGetColorizationColor(ref int pcrColorization, ref int pfOpaqueBlend);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmGetCompositionTimingInfo(IntPtr hwnd, ref Dwm.DWM_TIMING_INFO pTimingInfo);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, IntPtr pvAttribute, int cbAttribute);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmIsCompositionEnabled(ref int pfEnabled);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmModifyPreviousDxFrameDuration(IntPtr hwnd, int cRefreshes, int fRelative);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmQueryThumbnailSourceSize(IntPtr hThumbnail, ref Size pSize);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmRegisterThumbnail(IntPtr hwndDestination, IntPtr hwndSource, ref Size pMinimizedSize, ref IntPtr phThumbnailId);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmSetDxFrameDuration(IntPtr hwnd, int cRefreshes);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmSetPresentParameters(IntPtr hwnd, ref Dwm.DWM_PRESENT_PARAMETERS pPresentParams);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, IntPtr pvAttribute, int cbAttribute);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmUnregisterThumbnail(IntPtr hThumbnailId);
- [DllImport("dwmapi.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int DwmUpdateThumbnailProperties(IntPtr hThumbnailId, ref Dwm.DWM_THUMBNAIL_PROPERTIES ptnProperties);
- /// <summary>
- /// Set The Window's Theme Attributes
- /// </summary>
- /// <param name="hWnd">The Handle to the Window</param>
- /// <param name="wtype">What Type of Attributes</param>
- /// <param name="attributes">The Attributes to Add/Remove</param>
- /// <param name="size">The Size of the Attributes Struct</param>
- /// <returns>If The Call Was Successful or Not</returns>
- [DllImport("UxTheme.dll", CharSet = CharSet.None, ExactSpelling = false)]
- public static extern int SetWindowThemeAttribute(IntPtr hWnd, Dwm.WindowThemeAttributeType wtype, ref Dwm.WTA_OPTIONS attributes, uint size);
- public struct DWM_BLURBEHIND
- {
- public int dwFlags;
- public int fEnable;
- public IntPtr hRgnBlur;
- public int fTransitionOnMaximized;
- }
- public struct DWM_PRESENT_PARAMETERS
- {
- public int cbSize;
- public int fQueue;
- public long cRefreshStart;
- public int cBuffer;
- public int fUseSourceRate;
- public Dwm.UNSIGNED_RATIO rateSource;
- public int cRefreshesPerFrame;
- public Dwm.DWM_SOURCE_FRAME_SAMPLING eSampling;
- }
- public enum DWM_SOURCE_FRAME_SAMPLING
- {
- DWM_SOURCE_FRAME_SAMPLING_POINT,
- DWM_SOURCE_FRAME_SAMPLING_COVERAGE,
- DWM_SOURCE_FRAME_SAMPLING_LAST
- }
- public struct DWM_THUMBNAIL_PROPERTIES
- {
- public int dwFlags;
- public Dwm.RECT rcDestination;
- public Dwm.RECT rcSource;
- public byte opacity;
- public int fVisible;
- public int fSourceClientAreaOnly;
- }
- public struct DWM_TIMING_INFO
- {
- public int cbSize;
- public Dwm.UNSIGNED_RATIO rateRefresh;
- public Dwm.UNSIGNED_RATIO rateCompose;
- public long qpcVBlank;
- public long cRefresh;
- public long qpcCompose;
- public long cFrame;
- public long cRefreshFrame;
- public long cRefreshConfirmed;
- public int cFlipsOutstanding;
- public long cFrameCurrent;
- public long cFramesAvailable;
- public long cFrameCleared;
- public long cFramesReceived;
- public long cFramesDisplayed;
- public long cFramesDropped;
- public long cFramesMissed;
- }
- public enum DWMNCRENDERINGPOLICY
- {
- DWMNCRP_USEWINDOWSTYLE,
- DWMNCRP_DISABLED,
- DWMNCRP_ENABLED
- }
- public enum DWMWINDOWATTRIBUTE
- {
- DWMWA_NCRENDERING_ENABLED = 1,
- DWMWA_NCRENDERING_POLICY = 2,
- DWMWA_TRANSITIONS_FORCEDISABLED = 3,
- DWMWA_ALLOW_NCPAINT = 4,
- DWMWA_CAPTION_BUTTON_BOUNDS = 5,
- DWMWA_NONCLIENT_RTL_LAYOUT = 6,
- DWMWA_FORCE_ICONIC_REPRESENTATION = 7,
- DWMWA_FLIP3D_POLICY = 8,
- DWMWA_LAST = 9
- }
- public struct MARGINS
- {
- public int cxLeftWidth;
- public int cxRightWidth;
- public int cyTopHeight;
- public int cyBottomHeight;
- public MARGINS(int Left, int Right, int Top, int Bottom)
- {
- this = new Dwm.MARGINS()
- {
- cxLeftWidth = Left,
- cxRightWidth = Right,
- cyTopHeight = Top,
- cyBottomHeight = Bottom
- };
- }
- }
- [StructLayout(LayoutKind.Explicit)]
- public struct RECT
- {
- [FieldOffset(12)]
- public int bottom;
- [FieldOffset(0)]
- public int left;
- [FieldOffset(8)]
- public int right;
- [FieldOffset(4)]
- public int top;
- public int Height
- {
- get
- {
- return checked(this.bottom - this.top);
- }
- }
- public Size Size
- {
- get
- {
- return new System.Drawing.Size(this.Width, this.Height);
- }
- }
- public int Width
- {
- get
- {
- return checked(this.right - this.left);
- }
- }
- public RECT(Rectangle rect)
- {
- this = new Dwm.RECT()
- {
- left = rect.Left,
- top = rect.Top,
- right = rect.Right,
- bottom = rect.Bottom
- };
- }
- public RECT(int left, int top, int right, int bottom)
- {
- this = new Dwm.RECT()
- {
- left = left,
- top = top,
- right = right,
- bottom = bottom
- };
- }
- private static T InlineAssignHelper<T>(ref T target, T value)
- {
- target = value;
- return value;
- }
- public void Set()
- {
- this.left = Dwm.RECT.InlineAssignHelper<int>(ref this.top, Dwm.RECT.InlineAssignHelper<int>(ref this.right, Dwm.RECT.InlineAssignHelper<int>(ref this.bottom, 0)));
- }
- public void Set(Rectangle rect)
- {
- this.left = rect.Left;
- this.top = rect.Top;
- this.right = rect.Right;
- this.bottom = rect.Bottom;
- }
- public void Set(int left, int top, int right, int bottom)
- {
- this.left = left;
- this.top = top;
- this.right = right;
- this.bottom = bottom;
- }
- public Rectangle ToRectangle()
- {
- Rectangle rectangle = new Rectangle(this.left, this.top, checked(this.right - this.left), checked(this.bottom - this.top));
- return rectangle;
- }
- }
- public struct UNSIGNED_RATIO
- {
- public int uiNumerator;
- public int uiDenominator;
- }
- public enum WindowThemeAttributeType
- {
- WTA_NONCLIENT = 1
- }
- /// <summary>
- /// The Options of What Attributes to Add/Remove
- /// </summary>
- public struct WTA_OPTIONS
- {
- public uint Flags;
- public uint Mask;
- }
- }
- public class WinApi
- {
- [DebuggerNonUserCode]
- public WinApi()
- {
- }
- public struct NCCALCSIZE_PARAMS
- {
- public WinApi.RECT rect0;
- public WinApi.RECT rect1;
- public WinApi.RECT rect2;
- public IntPtr lppos;
- }
- public struct RECT
- {
- public int Left;
- public int Top;
- public int Right;
- public int Bottom;
- }
- public enum Win32Messages : uint
- {
- WM_NULL = 0,
- WM_CREATE = 1,
- WM_DESTROY = 2,
- WM_MOVE = 3,
- WM_SIZE = 5,
- WM_ACTIVATE = 6,
- WM_SETFOCUS = 7,
- WM_KILLFOCUS = 8,
- WM_ENABLE = 10,
- WM_SETREDRAW = 11,
- WM_SETTEXT = 12,
- WM_GETTEXT = 13,
- WM_GETTEXTLENGTH = 14,
- WM_PAINT = 15,
- WM_CLOSE = 16,
- WM_QUERYENDSESSION = 17,
- WM_QUIT = 18,
- WM_QUERYOPEN = 19,
- WM_ERASEBKGND = 20,
- WM_SYSCOLORCHANGE = 21,
- WM_ENDSESSION = 22,
- WM_SHOWWINDOW = 24,
- WM_CTLCOLOR = 25,
- WM_SETTINGCHANGE = 26,
- WM_WININICHANGE = 26,
- WM_DEVMODECHANGE = 27,
- WM_ACTIVATEAPP = 28,
- WM_FONTCHANGE = 29,
- WM_TIMECHANGE = 30,
- WM_CANCELMODE = 31,
- WM_SETCURSOR = 32,
- WM_MOUSEACTIVATE = 33,
- WM_CHILDACTIVATE = 34,
- WM_QUEUESYNC = 35,
- WM_GETMINMAXINFO = 36,
- WM_PAINTICON = 38,
- WM_ICONERASEBKGND = 39,
- WM_NEXTDLGCTL = 40,
- WM_SPOOLERSTATUS = 42,
- WM_DRAWITEM = 43,
- WM_MEASUREITEM = 44,
- WM_DELETEITEM = 45,
- WM_VKEYTOITEM = 46,
- WM_CHARTOITEM = 47,
- WM_SETFONT = 48,
- WM_GETFONT = 49,
- WM_SETHOTKEY = 50,
- WM_GETHOTKEY = 51,
- WM_QUERYDRAGICON = 55,
- WM_COMPAREITEM = 57,
- WM_GETOBJECT = 61,
- WM_COMPACTING = 65,
- WM_COMMNOTIFY = 68,
- WM_WINDOWPOSCHANGING = 70,
- WM_WINDOWPOSCHANGED = 71,
- WM_POWER = 72,
- WM_COPYDATA = 74,
- WM_CANCELJOURNAL = 75,
- WM_NOTIFY = 78,
- WM_INPUTLANGCHANGEREQUEST = 80,
- WM_INPUTLANGCHANGE = 81,
- WM_TCARD = 82,
- WM_HELP = 83,
- WM_USERCHANGED = 84,
- WM_NOTIFYFORMAT = 85,
- WM_CONTEXTMENU = 123,
- WM_STYLECHANGING = 124,
- WM_STYLECHANGED = 125,
- WM_DISPLAYCHANGE = 126,
- WM_GETICON = 127,
- WM_SETICON = 128,
- WM_NCCREATE = 129,
- WM_NCDESTROY = 130,
- WM_NCCALCSIZE = 131,
- WM_NCHITTEST = 132,
- WM_NCPAINT = 133,
- WM_NCACTIVATE = 134,
- WM_GETDLGCODE = 135,
- WM_SYNCPAINT = 136,
- WM_NCMOUSEMOVE = 160,
- WM_NCLBUTTONDOWN = 161,
- WM_NCLBUTTONUP = 162,
- WM_NCLBUTTONDBLCLK = 163,
- WM_NCRBUTTONDOWN = 164,
- WM_NCRBUTTONUP = 165,
- WM_NCRBUTTONDBLCLK = 166,
- WM_NCMBUTTONDOWN = 167,
- WM_NCMBUTTONUP = 168,
- WM_NCMBUTTONDBLCLK = 169,
- WM_NCXBUTTONDOWN = 171,
- WM_NCXBUTTONUP = 172,
- WM_NCXBUTTONDBLCLK = 173,
- WM_INPUT = 255,
- WM_KEYDOWN = 256,
- WM_KEYFIRST = 256,
- WM_KEYUP = 257,
- WM_CHAR = 258,
- WM_DEADCHAR = 259,
- WM_SYSKEYDOWN = 260,
- WM_SYSKEYUP = 261,
- WM_SYSCHAR = 262,
- WM_SYSDEADCHAR = 263,
- WM_KEYLAST = 264,
- WM_UNICHAR = 265,
- WM_IME_STARTCOMPOSITION = 269,
- WM_IME_ENDCOMPOSITION = 270,
- WM_IME_COMPOSITION = 271,
- WM_IME_KEYLAST = 271,
- WM_INITDIALOG = 272,
- WM_COMMAND = 273,
- WM_SYSCOMMAND = 274,
- WM_TIMER = 275,
- WM_HSCROLL = 276,
- WM_VSCROLL = 277,
- WM_INITMENU = 278,
- WM_INITMENUPOPUP = 279,
- WM_MENUSELECT = 287,
- WM_MENUCHAR = 288,
- WM_ENTERIDLE = 289,
- WM_MENURBUTTONUP = 290,
- WM_MENUDRAG = 291,
- WM_MENUGETOBJECT = 292,
- WM_UNINITMENUPOPUP = 293,
- WM_MENUCOMMAND = 294,
- WM_CHANGEUISTATE = 295,
- WM_UPDATEUISTATE = 296,
- WM_QUERYUISTATE = 297,
- WM_CTLCOLORMSGBOX = 306,
- WM_CTLCOLOREDIT = 307,
- WM_CTLCOLORLISTBOX = 308,
- WM_CTLCOLORBTN = 309,
- WM_CTLCOLORDLG = 310,
- WM_CTLCOLORSCROLLBAR = 311,
- WM_CTLCOLORSTATIC = 312,
- WM_MOUSEFIRST = 512,
- WM_MOUSEMOVE = 512,
- WM_LBUTTONDOWN = 513,
- WM_LBUTTONUP = 514,
- WM_LBUTTONDBLCLK = 515,
- WM_RBUTTONDOWN = 516,
- WM_RBUTTONUP = 517,
- WM_RBUTTONDBLCLK = 518,
- WM_MBUTTONDOWN = 519,
- WM_MBUTTONUP = 520,
- WM_MBUTTONDBLCLK = 521,
- WM_MOUSEWHEEL = 522,
- WM_XBUTTONDOWN = 523,
- WM_XBUTTONUP = 524,
- WM_MOUSELAST = 525,
- WM_XBUTTONDBLCLK = 525,
- WM_PARENTNOTIFY = 528,
- WM_ENTERMENULOOP = 529,
- WM_EXITMENULOOP = 530,
- WM_NEXTMENU = 531,
- WM_SIZING = 532,
- WM_CAPTURECHANGED = 533,
- WM_MOVING = 534,
- WM_POWERBROADCAST = 536,
- WM_DEVICECHANGE = 537,
- WM_MDICREATE = 544,
- WM_MDIDESTROY = 545,
- WM_MDIACTIVATE = 546,
- WM_MDIRESTORE = 547,
- WM_MDINEXT = 548,
- WM_MDIMAXIMIZE = 549,
- WM_MDITILE = 550,
- WM_MDICASCADE = 551,
- WM_MDIICONARRANGE = 552,
- WM_MDIGETACTIVE = 553,
- WM_MDISETMENU = 560,
- WM_ENTERSIZEMOVE = 561,
- WM_EXITSIZEMOVE = 562,
- WM_DROPFILES = 563,
- WM_MDIREFRESHMENU = 564,
- WM_IME_SETCONTEXT = 641,
- WM_IME_NOTIFY = 642,
- WM_IME_CONTROL = 643,
- WM_IME_COMPOSITIONFULL = 644,
- WM_IME_SELECT = 645,
- WM_IME_CHAR = 646,
- WM_IME_REQUEST = 648,
- WM_IME_KEYDOWN = 656,
- WM_IME_KEYUP = 657,
- WM_MOUSEHOVER = 673,
- WM_NCMOUSELEAVE = 674,
- WM_MOUSELEAVE = 675,
- WM_WTSSESSION_CHANGE = 689,
- WM_TABLET_FIRST = 704,
- WM_TABLET_LAST = 735,
- WM_CUT = 768,
- WM_COPY = 769,
- WM_PASTE = 770,
- WM_CLEAR = 771,
- WM_UNDO = 772,
- WM_RENDERFORMAT = 773,
- WM_RENDERALLFORMATS = 774,
- WM_DESTROYCLIPBOARD = 775,
- WM_DRAWCLIPBOARD = 776,
- WM_PAINTCLIPBOARD = 777,
- WM_VSCROLLCLIPBOARD = 778,
- WM_SIZECLIPBOARD = 779,
- WM_ASKCBFORMATNAME = 780,
- WM_CHANGECBCHAIN = 781,
- WM_HSCROLLCLIPBOARD = 782,
- WM_QUERYNEWPALETTE = 783,
- WM_PALETTEISCHANGING = 784,
- WM_PALETTECHANGED = 785,
- WM_HOTKEY = 786,
- WM_PRINT = 791,
- WM_PRINTCLIENT = 792,
- WM_APPCOMMAND = 793,
- WM_THEMECHANGED = 794,
- WM_HANDHELDFIRST = 856,
- WM_HANDHELDLAST = 863,
- WM_AFXFIRST = 864,
- WM_AFXLAST = 895,
- WM_PENWINFIRST = 896,
- WM_PENWINLAST = 911,
- WM_USER = 1024,
- WM_REFLECT = 8192,
- WM_APP = 32768
- }
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment