VC里面有一个WM_NCMOUSMOVE这个消息,后来发现C#里面有一个WinProc(),从里面可以响应此鼠标的非工作区移动消息,而且通过获取标题栏的宽度来锁定鼠标响应位置。
部分代吗如下:
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == 0xA0)//wm_ncmousemove
{
Point p = new Point((int)m.LParam);
int widthtitlebar = this.Height - this.ClientRectangle.Height;//标题栏的宽度
// int widthtitlebar = SystemInformation.CaptionHeight;
if (p.Y >= this.Top && p.Y <= (this.Top + widthtitlebar) && p.X < this.ClientRectangle.Width)
this.MainMenuStrip.Visible = true;
}
}
另外,从别处收集了一些获取Winform窗体、工作区 宽度、高度、命名空间、菜单栏高度的公式
MessageBox.Show("当前窗体标题栏高度"+(this.Height-this.ClientRectangle.Height).ToString());//获得当前窗体标题栏高度
ClientRectangle//获取表示控件的工作区的矩形
MessageBox.Show(SystemInformation.PrimaryMonitorSize.ToString());//获取主显示器屏幕的尺寸(像素)
//获取主显示器当前当前视频模式的尺寸(以象素为单位)
MessageBox.Show("菜单栏高度"+SystemInformation.MenuHeight.ToString()); //获取标准菜单栏的高度
MessageBox.Show("标题栏高度"+SystemInformation.CaptionHeight.ToString());//获取标准标题栏的高度
MenuHeight//获取一个菜单行的高度(以象素为单位)
CaptionHeight//获取窗口的标准标题栏区域的高度(以象素为单位)
control.FindForm().GetType().FullName;//获取命名空间名称