1 using System.ComponentModel;
2 using System.Drawing;
3 using System.Windows.Forms;
4 
5 namespace WeifenLuo.WinFormsUI.Docking
6 {
7     [ToolboxItem(false)]
8     public class SplitterBase : Control
9     {
SplitterBase()10         public SplitterBase()
11         {
12             SetStyle(ControlStyles.Selectable, false);
13         }
14 
15         public override DockStyle Dock
16         {
17             get	{	return base.Dock;	}
18             set
19             {
20                 SuspendLayout();
21                 base.Dock = value;
22 
23                 if (Dock == DockStyle.Left || Dock == DockStyle.Right)
24                     Width = SplitterSize;
25                 else if (Dock == DockStyle.Top || Dock == DockStyle.Bottom)
26                     Height = SplitterSize;
27                 else
28                     Bounds = Rectangle.Empty;
29 
30                 if (Dock == DockStyle.Left || Dock == DockStyle.Right)
31                     Cursor = Cursors.VSplit;
32                 else if (Dock == DockStyle.Top || Dock == DockStyle.Bottom)
33                     Cursor = Cursors.HSplit;
34                 else
35                     Cursor = Cursors.Default;
36 
37                 ResumeLayout();
38             }
39         }
40 
41         protected virtual int SplitterSize
42         {
43             get	{	return 0;	}
44         }
45 
OnMouseDown(MouseEventArgs e)46         protected override void OnMouseDown(MouseEventArgs e)
47         {
48             base.OnMouseDown(e);
49 
50             if (e.Button != MouseButtons.Left)
51                 return;
52 
53             StartDrag();
54         }
55 
StartDrag()56         protected virtual void StartDrag()
57         {
58         }
59 
WndProc(ref Message m)60         protected override void WndProc(ref Message m)
61         {
62             // eat the WM_MOUSEACTIVATE message
63             if (m.Msg == (int)Win32.Msgs.WM_MOUSEACTIVATE)
64                 return;
65 
66             base.WndProc(ref m);
67         }
68     }
69 }
70