123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- namespace FastReport.Controls
- {
- internal sealed class ExtListView : ListView
- {
- public event EventHandler FetchMoreItems;
- private void OnScroll()
- {
- var scrollInfo = GetFullScrollInfo(false);
- if (scrollInfo.nMax - scrollInfo.nPage < scrollInfo.nPos)
- {
- FetchMoreItems?.Invoke(this, EventArgs.Empty);
- }
- }
- protected override void WndProc(ref Message m)
- {
- base.WndProc(ref m);
- if (m.Msg == 0x115 || (m.Msg == 0x114) || (m.Msg == 0x020A))
- {
- //Trap WM_VSCROLL
- this.OnScroll();
- }
- }
- private const int SIF_RANGE = 0x0001;
- private const int SIF_PAGE = 0x0002;
- private const int SIF_POS = 0x0004;
- private const int SIF_TRACKPOS = 0x0010;
- private const int SIF_ALL = (SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS);
- private const int SB_HORZ = 0;
- private const int SB_VERT = 1;
- [StructLayout(LayoutKind.Sequential)]
- private class SCROLLINFO
- {
- public int cbSize = Marshal.SizeOf(typeof(SCROLLINFO));
- public int fMask;
- public int nMin;
- public int nMax;
- public int nPage;
- public int nPos;
- public int nTrackPos;
- }
- [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
- private static extern bool GetScrollInfo(IntPtr hWnd, int fnBar, SCROLLINFO scrollInfo);
- private SCROLLINFO GetFullScrollInfo(bool horizontalBar)
- {
- int fnBar = (horizontalBar ? SB_HORZ : SB_VERT);
- SCROLLINFO scrollInfo = new SCROLLINFO();
- scrollInfo.fMask = SIF_ALL;
- if (GetScrollInfo(Handle, fnBar, scrollInfo))
- return scrollInfo;
- else
- return null;
- }
- }
- }
|