鼠标移动到form边框触发事件
怎么判断鼠标是否移动到左边框、右边框和顶边框。
------解决方案--------------------
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref m);
if ((int)m.Result == HTTOPLEFT)
MessageBox.Show("左边框");
if ((int)m.Result == HTTOP)
MessageBox.Show("水平边框");
if((int)m.Result==HTRIGHT)
MessageBox.Show("右边框");
if ((int)m.Result == HTLEFT)
MessageBox.Show("左边框");
return;
//case WM_NCLBUTTONDBLCLK:
break;
default:
base.WndProc(ref m);
break;
}
}
------解决方案--------------------重载WndProc,捕获 WM_NCHITTEST 消息
或实时判断鼠标位置