Listing 3: The application subclasses the listview control so that scrolling only occurs when the left mouse button is released. SB_THUMBTRACK messages don't scroll, but the application does save the thumb position

LRESULT CALLBACK ListViewWndProc(
  HWND   hWndLV, UINT   message, WPARAM wParam, LPARAM lParam)
{
  static int    iOldThumb = 0;
  static int    iPageSize;       // in rows
  static int    iItemCount;
  static SCROLLINFO si;

  si.fMask  = SIF_ALL;
  si.cbSize = sizeof si;
  
  switch(message)
  {
    ...
    case WM_VSCROLL:
      switch (LOWORD(wParam))
      {
        case SB_ENDSCROLL:
          return 0;
        case SB_THUMBPOSITION:
        {
          int iNewThumb = si.nTrackPos, idx;
          
          idx = (iNewThumb >= iOldThumb ? min(iItemCount - 1, 
                   iNewThumb + iPageSize - 1) : iNewThumb);
          ListView_EnsureVisible(hWndLV,idx,FALSE); 
          iOldThumb = idx;
          return 0; 
        }

        // Don't scroll,just keep track of thumb position
        case SB_THUMBTRACK:
          GetScrollInfo(hWndLV,SB_VERT,&si);
          return 0;
        default:break;
      }
      break;
    default :;
  }
    
  return CallWindowProc(g_pfnOldLVProc, hWndLV, message, 
   wParam, lParam);
}
//End of File