| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 | using System.ComponentModel;using System.Drawing;using System.Windows.Forms;namespace PaintDotNet.SystemLayer{    /// <summary>    /// This is the same as System.Windows.Forms.Panel except for three things:    /// 1. It exposes a Scroll event.    /// 2. It allows you to disable SetFocus.    /// 3. It has a much simplified interface for AutoScrollPosition, exposed via the ScrollPosition property.    /// </summary>    public class ScrollPanel : Panel    {        private bool ignoreSetFocus = false;        /// <summary>        /// Gets or sets whether the control ignores WM_SETFOCUS.        /// </summary>        public bool IgnoreSetFocus        {            get            {                return ignoreSetFocus;            }            set            {                ignoreSetFocus = value;            }        }        /// <summary>        /// Gets or sets the scrollbar position.        /// </summary>        [Browsable(false)]        public Point ScrollPosition        {            get            {                return new Point(-AutoScrollPosition.X, -AutoScrollPosition.Y);            }            set            {                AutoScrollPosition = value;            }        }        protected override void WndProc(ref Message m)        {            switch (m.Msg)            {                case NativeConstants.WM_SETFOCUS:                    if (IgnoreSetFocus)                    {                        return;                    }                    else                    {                        goto default;                    }                default:                    base.WndProc(ref m);                    break;            }        }    }}
 |