Listing 5: The virtual listbox's WM_NOTIFY handler. LVN_GETDISPINFO gets a string from the page cache, paging in if necessary. LVN_COLUMNCLICK tells the application to call IMAPITable::SortTable on the clicked column's property

LRESULT
ListViewNotify(PCSession pCSess, HWND hWnd, LPARAM lParam)
{
  LPNMHDR  pnmh = (LPNMHDR) lParam;

  switch(pnmh -> code)
  {
     case LVN_GETDISPINFO:
     {
      // we get here when listview needs more data
      LV_DISPINFO *lpdi = (LV_DISPINFO *)lParam;
      TCHAR     szCol[MAX_PATH];
      int iRow = lpdi -> item.iItem, iCol = lpdi -> item.iSubItem;
      ...

      // Listview needs a string, return if from cache
      if (lpdi->item.mask & LVIF_TEXT)
        lstrcpy(lpdi -> item.pszText,  
          pCSess -> m_PageCache.GetTableString(iRow, iCol, szCol));
      return 0;
    }
    ...
    case LVN_COLUMNCLICK:
      // user clicked column heading, sort on that column
     pCSess->SortOnColumn((NM_LISTVIEW *) lParam);
     return 0;
  }  
  return 0;
}
//End of File