ListViewEx.cs 787 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (c) 2012-2020 fo-dicom contributors.
  2. // Licensed under the Microsoft Public License (MS-PL).
  3. using System.Windows.Forms;
  4. namespace Dicom.Compare
  5. {
  6. internal class ListViewEx : ListView
  7. {
  8. private const int WM_VSCROLL = 0x0115;
  9. private const int WM_MOUSEWHEEL = 0x020A;
  10. public event ScrollEventHandler Scroll;
  11. protected virtual void OnScroll(ScrollEventArgs e)
  12. {
  13. Scroll?.Invoke(this, e);
  14. }
  15. protected override void WndProc(ref Message m)
  16. {
  17. base.WndProc(ref m);
  18. if (m.Msg == WM_VSCROLL) OnScroll(new ScrollEventArgs((ScrollEventType)(m.WParam.ToInt32() & 0xffff), 0));
  19. else if (m.Msg == WM_MOUSEWHEEL) OnScroll(new ScrollEventArgs(ScrollEventType.EndScroll, 0));
  20. }
  21. }
  22. }