public void MouseDownColor(MouseDownStyle ms, Message m) { Point mousePoint = new Point((int)m.LParam); mousePoint.Offset(-this.Left, -this.Top); Rectangle col; IntPtr hDC = GetWindowDC(m.HWnd); Graphics gs = Graphics.FromHdc(hDC); LinearGradientBrush bBackground; StringFormat strFmt = new StringFormat(); strFmt.Alignment = StringAlignment.Center; strFmt.LineAlignment = StringAlignment.Center; switch (ms) { case MouseDownStyle.Max: { col = new Rectangle(Max_rect.X, 0, Max_rect.Width, Max_rect.Height); bBackground = new System.Drawing.Drawing2D.LinearGradientBrush(col, MouseDownColor1, MouseDownColor2, LinearGradientMode.Vertical); gs.FillRectangle(bBackground, col); gs.DrawString("□", font, Brushes.BlanchedAlmond, Max_rect, strFmt); gs.Dispose(); ReleaseDC(m.HWnd, hDC); break; } case MouseDownStyle.Min: { col = new Rectangle(Min_rect.X, 0, Min_rect.Width, Min_rect.Height); bBackground = new System.Drawing.Drawing2D.LinearGradientBrush(col, MouseDownColor1, MouseDownColor2, LinearGradientMode.Vertical); gs.FillPath(bBackground, CreateRoundedRectanglePath(col, RoundDirect.LeftDown, Radius)); gs.DrawString("—", font, Brushes.BlanchedAlmond, Min_rect, strFmt); gs.Dispose(); ReleaseDC(m.HWnd, hDC); break; } case MouseDownStyle.Close: { col = new Rectangle(Close_rect.X, 0, Close_rect.Width, Close_rect.Height); bBackground = new System.Drawing.Drawing2D.LinearGradientBrush(col, Color.Red, Color.Black, LinearGradientMode.Vertical); gs.FillPath(bBackground, CreateRoundedRectanglePath(col, RoundDirect.RightDown, Radius)); gs.DrawString("×", font, Brushes.BlanchedAlmond, Close_rect, strFmt); gs.Dispose(); ReleaseDC(m.HWnd, hDC); break; } } }