昨天在做項目的時候想實現一下這個功能.也是在網上找了幾種方法.挑了個比較簡單的(我比較懶) ,效果還行,只是用了這個鼠標的其他事件都不管用了. 不知道要怎麼解決這個問題
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
protected override void WndProc(ref Message m)
{
const int WM_NCHITTEST = 0x84;
const int HTCLIENT = 0x01;
const int HTCAPTION = 0x02;
if (m.Msg == WM_NCHITTEST)
{
this.DefWndProc(ref m);
if (m.Result.ToInt32() == HTCLIENT)
m.Result = new IntPtr(HTCAPTION);
else
base.WndProc(ref m);
}
else
base.WndProc(ref m);
}