在消息响应 protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == WM_NCHITTEST)
{
base.WndProc(ref m);
if (m.Result == HTCLIENT)
{
m.Result = HTCAPTION;//模拟标题栏,移动或双击可以最大或最小化窗体
}
}
else
{
base.WndProc(ref m);
}
}
这样的话就拦截了鼠标的右击消息(以下代码是无效的了就) private void Form4_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
//
}
}请问各位怎么能使得消息响应正确处理的情况下,也能处理鼠标的右击消息呢??
{
if (m.Msg == WM_NCHITTEST)
{
base.WndProc(ref m);
if (m.Result == HTCLIENT)
{
m.Result = HTCAPTION;//模拟标题栏,移动或双击可以最大或最小化窗体
}
}
else
{
base.WndProc(ref m);
}
}
这样的话就拦截了鼠标的右击消息(以下代码是无效的了就) private void Form4_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
//
}
}请问各位怎么能使得消息响应正确处理的情况下,也能处理鼠标的右击消息呢??
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
public const int WM_NCLBUTTONDBLCLK = 0xA3;
private void Form3_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(this.Handle, WM_NCLBUTTONDBLCLK, HTCAPTION, 0); //模拟 双击 }
} private void Form3_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);//模拟标题栏,移动 }
}
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
谢谢你啊
分都给你喂