您的位置:首页 > 编程语言 > C#

C# 在winform中隐藏或者去除c#的标题栏并实现窗体移动附代码

2015-04-18 11:33 519 查看
设置窗体的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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: