protected override void OnLayout(LayoutEventArgs levent) { //SetBrush(); // set the size and location for close and auto-hide buttons Rectangle rectCaption = ClientRectangle; int buttonWidth = ImageCloseEnabled.Width; int buttonHeight = ImageCloseEnabled.Height; int height = rectCaption.Height - ButtonGapTop - ButtonGapBottom; if (buttonHeight < height) { buttonWidth = buttonWidth * (height / buttonHeight); buttonHeight = height; } m_buttonClose.SuspendLayout(); m_buttonAutoHide.SuspendLayout(); m_buttonWhatIsIt.SuspendLayout(); Size buttonSize = new Size(buttonWidth, buttonHeight); m_buttonClose.Size = m_buttonAutoHide.Size = m_buttonWhatIsIt.Size = buttonSize; int x = rectCaption.X + rectCaption.Width - 1 - ButtonGapRight - m_buttonClose.Width; int y = rectCaption.Y + ButtonGapTop; Point point = m_buttonClose.Location = new Point(x, y); point.Offset(-(m_buttonAutoHide.Width + ButtonGapBetween), 0); m_buttonAutoHide.Location = point; point.Offset(-(m_buttonWhatIsIt.Width + ButtonGapBetween), 0); m_buttonWhatIsIt.Location = point; m_buttonClose.ResumeLayout(); m_buttonAutoHide.ResumeLayout(); base.OnLayout(levent); }