首页 > 代码库 > C# 隐藏标题栏 调整大小 并且移动窗口

C# 隐藏标题栏 调整大小 并且移动窗口

隐藏标题栏(窗口属性):

1、设置在该窗体的标题栏中是否显示控件框:

this.ControlBox = false;

2、设置在该窗体的标题为空:

this.Text = string.Empty;

3、移动窗口:实现Form的函数WndProc

        #region 实现点击移动        internal static int WM_NCHITTEST = 0x84;        internal static IntPtr HTCLIENT = (IntPtr)0x1;        internal static IntPtr HTCAPTION = (IntPtr)0x2;        internal static int WM_NCLBUTTONDBLCLK = 0x00A3;        protected override void WndProc(ref Message m)        {            if (m.Msg == WM_NCLBUTTONDBLCLK)            {                return;            }            if (m.Msg == WM_NCHITTEST)            {                base.WndProc(ref m);                if (m.Result == HTCLIENT)                {                    m.HWnd = this.Handle;                    m.Result = HTCAPTION;                }                return;            }            base.WndProc(ref m);        }        #endregion