SplitterBase.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:SplitterBase.cs
  5. * 2.功能描述:类文件
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2014/09/01 1.00 新建
  9. *******************************************************************************/
  10. using System.Drawing;
  11. using System.Windows.Forms;
  12. namespace Dongke.IBOSS.PRD.Basics.DockPanel
  13. {
  14. internal class SplitterBase : Control
  15. {
  16. public SplitterBase()
  17. {
  18. SetStyle(ControlStyles.Selectable, false);
  19. }
  20. public override DockStyle Dock
  21. {
  22. get
  23. {
  24. return base.Dock;
  25. }
  26. set
  27. {
  28. SuspendLayout();
  29. base.Dock = value;
  30. if (Dock == DockStyle.Left || Dock == DockStyle.Right)
  31. Width = SplitterSize;
  32. else if (Dock == DockStyle.Top || Dock == DockStyle.Bottom)
  33. Height = SplitterSize;
  34. else
  35. Bounds = Rectangle.Empty;
  36. if (Dock == DockStyle.Left || Dock == DockStyle.Right)
  37. Cursor = Cursors.VSplit;
  38. else if (Dock == DockStyle.Top || Dock == DockStyle.Bottom)
  39. Cursor = Cursors.HSplit;
  40. else
  41. Cursor = Cursors.Default;
  42. ResumeLayout();
  43. }
  44. }
  45. protected virtual int SplitterSize
  46. {
  47. get
  48. {
  49. return 0;
  50. }
  51. }
  52. protected override void OnMouseDown(MouseEventArgs e)
  53. {
  54. base.OnMouseDown(e);
  55. if (e.Button != MouseButtons.Left)
  56. return;
  57. StartDrag();
  58. }
  59. protected virtual void StartDrag()
  60. {
  61. }
  62. protected override void WndProc(ref Message m)
  63. {
  64. // eat the WM_MOUSEACTIVATE message
  65. if (m.Msg == (int)Win32.Msgs.WM_MOUSEACTIVATE)
  66. return;
  67. base.WndProc(ref m);
  68. }
  69. }
  70. }