예제 #1
0
        /// <summary>
        /// 引发 System.Windows.Forms.Form.MouseDown。
        /// </summary>
        /// <param name="e">包含事件数据的 System.Windows.Forms.MouseEventArgs。</param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            var point = e.Location;

            if (e.Button == MouseButtons.Right)
            {
                if (this.TitleBarRect.Contains(point) && !SysBtnRect.Contains(point))
                {
                    var  menu   = NativeMethods.GetSystemMenu(this.Handle, false);
                    RECT rect   = new RECT();
                    var  result = NativeMethods.TrackPopupMenu(menu, (int)WindowsMessage.WM_KEYDOWN, MousePosition.X, MousePosition.Y, 0, this.Handle, ref rect);
                    MenuClick((MenuType)result);
                }
                return;
            }

            if (CloseContains(point))
            {
                CloseState = TMouseState.Down;
            }
            else if (MiniRect.Contains(point))
            {
                MinState = TMouseState.Down;
            }
            else if (MaxRect.Contains(point))
            {
                MaxState = TMouseState.Down;
            }
            if ((_sysButton == TSysButton.Normal || _sysButton == TSysButton.Close_Max) && e.Clicks == 2)
            {
                WindowMax();
            }
        }
예제 #2
0
 /// <summary>
 /// 按下
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (e.Clicks == 2)
         {
             Close();
         }
         else if (isExceed && rect.Contains(e.Location) && !SysBtnRect.Contains(e.Location))
         {
             isMove = true;
             pStart = e.Location;
         }
     }
     if (!isMove)
     {
         base.OnMouseDown(e);
     }
 }
예제 #3
0
 /// <summary>
 /// 坐标点是否包含在项中
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public override bool Contain(Point p)
 {
     return(SysBtnRect.Contains(p));
 }