// //override WndProc // protected override void WndProc(ref Message m) { //**************************************************************************** int x = (int)(m.LParam.ToInt64() & 0xFFFF); //get x mouse position int y = (int)((m.LParam.ToInt64() & 0xFFFF0000) >> 16); //get y mouse position you can gave (x,y) it from "MouseEventArgs" too Point pt = PointToClient(new Point(x, y)); if (m.Msg == 0x84) { switch (resize.getMosuePosition(pt, this)) { case "l": m.Result = (IntPtr)10; return; // the Mouse on Left Form case "r": m.Result = (IntPtr)11; return; // the Mouse on Right Form case "a": m.Result = (IntPtr)12; return; case "la": m.Result = (IntPtr)13; return; case "ra": m.Result = (IntPtr)14; return; case "u": m.Result = (IntPtr)15; return; case "lu": m.Result = (IntPtr)16; return; case "ru": m.Result = (IntPtr)17; return; // the Mouse on Right_Under Form case "": m.Result = pt.Y < 32 /*mouse on title Bar*/ ? (IntPtr)2 : (IntPtr)1; return; } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { int x = (int)(m.LParam.ToInt64() & 0xFFFF); int y = (int)((m.LParam.ToInt64() & 0xFFFF0000) >> 16); Point pt = PointToClient(new Point(x, y)); if (m.Msg == 0x84) { switch (resize.getMosuePosition(pt, this)) { case "l": m.Result = (IntPtr)10; return; case "r": m.Result = (IntPtr)11; return; case "a": m.Result = (IntPtr)12; return; case "la": m.Result = (IntPtr)13; return; case "ra": m.Result = (IntPtr)14; return; case "u": m.Result = (IntPtr)15; return; case "lu": m.Result = (IntPtr)16; return; case "ru": m.Result = (IntPtr)17; return; case "": m.Result = pt.Y < 32 ? (IntPtr)2 : (IntPtr)1; return; } } switch (m.Msg) { case WM_NCPAINT: if (m_aeroEnabled) { var v = 2; DwmSetWindowAttribute(this.Handle, 2, ref v, 4); Margins margins = new Margins() { bottomHeight = 1, leftWidth = 1, rightWidth = 1, topHeight = 1 }; DwmExtendFrameIntoClientArea(this.Handle, ref margins); } break; default: break; } base.WndProc(ref m); if (m.Msg == WM_NCHITTEST && (int)m.Result == HTCLIENT) { m.Result = (IntPtr)HTCAPTION; } }