Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. public Form4()
  2. {
  3. InitializeComponent();
  4. this.SuspendLayout();
  5. //
  6. // scrolled
  7. //
  8. this.ResumeLayout(false);
  9. listBox20.OnVerticalScroll += this.syncListView1_OnVerticalScroll;
  10. listBox21.OnVerticalScroll += this.syncListView2_OnVerticalScroll;
  11.  
  12. }
  13.  
  14. public void OnVerticalScroll()
  15. {
  16.  
  17. }
  18.  
  19.  
  20. [Category("Action")]
  21. private const int WM_HSCROLL = 0x114;
  22. private const int WM_VSCROLL = 0x115;
  23.  
  24.  
  25. private const int SB_LINEUP = 0;
  26. private const int SB_LINELEFT = 0;
  27. private const int SB_LINEDOWN = 1;
  28. private const int SB_LINERIGHT = 1;
  29. private const int SB_PAGEUP = 2;
  30. private const int SB_PAGELEFT = 2;
  31. private const int SB_PAGEDOWN = 3;
  32. private const int SB_PAGERIGHT = 3;
  33. private const int SB_THUMBPOSITION = 4;
  34. private const int SB_THUMBTRACK = 5;
  35. private const int SB_PAGETOP = 6;
  36. private const int SB_LEFT = 6;
  37. private const int SB_PAGEBOTTOM = 7;
  38. private const int SB_RIGHT = 7;
  39. private const int SB_ENDSCROLL = 8;
  40. private const int SIF_TRACKPOS = 0x10;
  41. private const int SIF_RANGE = 0x1;
  42. private const int SIF_POS = 0x4;
  43. private const int SIF_PAGE = 0x2;
  44. private const int SIF_ALL = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;
  45. [DllImport("user32.dll", SetLastError = true)]
  46. private static extern int GetScrollInfo(
  47. IntPtr hWnd, int n, ref ScrollInfoStruct lpScrollInfo);
  48.  
  49. private struct ScrollInfoStruct
  50. {
  51. public int cbSize;
  52. public int fMask;
  53. public int nMin;
  54. public int nMax;
  55. public int nPage;
  56. public int nPos;
  57. public int nTrackPos;
  58. }
  59. protected override void WndProc(ref System.Windows.Forms.Message msg)
  60. {
  61. if (msg.Msg == WM_HSCROLL)
  62. {
  63. if (OnHorizontalScroll != null)
  64. {
  65. ScrollInfoStruct si = new ScrollInfoStruct();
  66. si.fMask = SIF_ALL;
  67. si.cbSize = Marshal.SizeOf(si);
  68. GetScrollInfo(msg.HWnd, 0, ref si);
  69. if (msg.WParam.ToInt32() == SB_ENDSCROLL)
  70. {
  71. ScrollEventArgs sargs = new ScrollEventArgs(
  72. ScrollEventType.EndScroll,
  73. si.nPos);
  74. OnHorizontalScroll(this, sargs);
  75. }
  76. }
  77. }
  78. if (msg.Msg == WM_VSCROLL)
  79. {
  80. if (OnVerticalScroll != null)
  81. {
  82. ScrollInfoStruct si = new ScrollInfoStruct();
  83. si.fMask = SIF_ALL;
  84. si.cbSize = Marshal.SizeOf(si);
  85. GetScrollInfo(msg.HWnd, 0, ref si);
  86. if (msg.WParam.ToInt32() == SB_ENDSCROLL)
  87. {
  88. ScrollEventArgs sargs = new ScrollEventArgs(
  89. ScrollEventType.EndScroll,
  90. si.nPos);
  91. OnVerticalScroll(this, sargs);
  92. }
  93. }
  94. }
  95. base.WndProc(ref msg);
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement