FqbCheckedListBox.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using System.ComponentModel;
  6. namespace FastReport.FastQueryBuilder
  7. {
  8. #if !DEBUG
  9. [DesignTimeVisible(false)]
  10. #endif
  11. class FqbCheckedListBox : CheckedListBox
  12. {
  13. private const int WM_HSCROLL = 0x114;
  14. private const int WM_VSCROLL = 0x115;
  15. public event ScrollEventHandler HorzScrollValueChanged;
  16. public event ScrollEventHandler VertScrollValueChanged;
  17. protected override void WndProc(ref Message m)
  18. {
  19. base.WndProc (ref m);
  20. if ( m.Msg == WM_HSCROLL )
  21. {
  22. if ( HorzScrollValueChanged != null )
  23. {
  24. uint wParam = (uint)m.WParam.ToInt32();
  25. HorzScrollValueChanged( this,
  26. new ScrollEventArgs(
  27. GetEventType( wParam & 0xffff), (int)(wParam >> 16) ) );
  28. }
  29. }
  30. else if ( m.Msg == WM_VSCROLL )
  31. {
  32. if ( VertScrollValueChanged != null )
  33. {
  34. uint wParam = (uint)m.WParam.ToInt32();
  35. VertScrollValueChanged( this,
  36. new ScrollEventArgs(
  37. GetEventType( wParam & 0xffff), (int)(wParam >> 16) ) );
  38. }
  39. }
  40. }
  41. private static ScrollEventType [] _events =
  42. new ScrollEventType[] {
  43. ScrollEventType.SmallDecrement,
  44. ScrollEventType.SmallIncrement,
  45. ScrollEventType.LargeDecrement,
  46. ScrollEventType.LargeIncrement,
  47. ScrollEventType.ThumbPosition,
  48. ScrollEventType.ThumbTrack,
  49. ScrollEventType.First,
  50. ScrollEventType.Last,
  51. ScrollEventType.EndScroll
  52. };
  53. private ScrollEventType GetEventType( uint wParam )
  54. {
  55. if ( wParam < _events.Length )
  56. return _events[wParam];
  57. else
  58. return ScrollEventType.EndScroll;
  59. }
  60. }
  61. }