using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace PaintDotNet.SystemLayer
{
///
/// 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.
///
public class ScrollPanel : Panel
{
private bool ignoreSetFocus = false;
///
/// Gets or sets whether the control ignores WM_SETFOCUS.
///
public bool IgnoreSetFocus
{
get
{
return ignoreSetFocus;
}
set
{
ignoreSetFocus = value;
}
}
///
/// Gets or sets the scrollbar position.
///
[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;
}
}
}
}