C# 在winform中隱藏或者去除c#的標題欄並實現窗體移動附程式碼
阿新 • • 發佈:2019-01-29
設定窗體的FormBorderStyle為None
不過要自己加上一些相應的操作程式碼了,不然視窗是不能進行拖動關閉之類的
#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