protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (CaptionRect.Contains(e.Location)) { CaptionState = ControlState.Pressed; OnCaptionMouseDown(e); } }
protected override void OnMouseCaptureChanged(EventArgs e) { base.OnMouseCaptureChanged(e); if (CaptionState == ControlState.Pressed && !CaptionRect.Contains(base.PointToClient(Control.MousePosition))) { CaptionState = ControlState.Normal; OnCaptionMouseLeave(e); System.Diagnostics.Trace.WriteLine("============================"); } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (CaptionState == ControlState.Pressed && CaptionRect.Contains(e.Location)) { CaptionState = ControlState.Hover; OnCaptionMouseUp(e); OnCaptionMouseClick(e); } }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (CaptionRect.Contains(e.Location)) { if (CaptionState == ControlState.Normal) { CaptionState = ControlState.Hover; OnCaptionMouseEnter(e); } OnCaptionMouseMove(e); } else { if (CaptionState == ControlState.Hover) { CaptionState = ControlState.Normal; OnCaptionMouseLeave(e); } } }
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); }