protected override void WndProc(ref Message message) { base.WndProc(ref message); if (message.Msg == 0x84) // WM_NCHITTEST { var cursor = this.PointToClient(Cursor.Position); if (TopLeftRect.Contains(cursor)) { message.Result = (IntPtr)HTTOPLEFT; } else if (TopRightRect.Contains(cursor)) { message.Result = (IntPtr)HTTOPRIGHT; } else if (BottomLeftRect.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOMLEFT; } else if (BottomRightRect.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOMRIGHT; } else if (TopRect.Contains(cursor)) { message.Result = (IntPtr)HTTOP; } else if (LeftRect.Contains(cursor)) { message.Result = (IntPtr)HTLEFT; } else if (RightRect.Contains(cursor)) { message.Result = (IntPtr)HTRIGHT; } else if (BottomRect.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOM; } } }
private bool WmNcHitTest(ref Message m) { int para = m.LParam.ToInt32(); int x0 = WinAPI.LOWORD(para); int y0 = WinAPI.HIWORD(para); Point p = PointToClient(new Point(x0, y0)); if (Resizable) { if (TopLeftRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTTOPLEFT); return(true); } if (TopRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTTOP); return(true); } if (TopRightRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTTOPRIGHT); return(true); } if (LeftRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTLEFT); return(true); } if (RightRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTRIGHT); return(true); } if (BottomLeftRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTBOTTOMLEFT); return(true); } if (BottomRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTBOTTOM); return(true); } if (BottomRightRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTBOTTOMRIGHT); return(true); } } if (IconRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTSYSMENU); return(true); } if (CloseBoxRect.Contains(p) || MaxBoxRect.Contains(p) || MinBoxRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTCLIENT); return(true); } if (IsMdiContainer && _mdiBarController != null) { if (_mdiBarController.HitTestBounds.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTCLIENT); return(true); } } if (CaptionRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTCAPTION); return(true); } m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTCLIENT); return(true); }
private void WmNcHitTest(ref Message m) { int para = m.LParam.ToInt32(); int x0 = WinAPI.LOWORD(para); int y0 = WinAPI.HIWORD(para); Point p = PointToClient(new Point(x0, y0)); if (UseShadowToResize) { if (TopLeftRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTTOPLEFT); return; } if (TopRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTTOP); return; } if (TopRightRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTTOPRIGHT); return; } if (LeftRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTLEFT); return; } if (RightRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTRIGHT); return; } if (BottomLeftRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTBOTTOMLEFT); return; } if (BottomRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTBOTTOM); return; } if (BottomRightRect.Contains(p)) { m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTBOTTOMRIGHT); return; } } m.Result = new IntPtr((int)WinAPI.NCHITTEST.HTCLIENT); return; }