home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / internet / httpsvr / httpview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  15.2 KB  |  602 lines

  1. // HttpView.cpp : implementation of the CHttpSvrView class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1997-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14.  
  15. #include "HttpSvr.h"
  16. #include "Http.h"
  17. #include "HttpDoc.h"
  18. #include "HttpView.h"
  19. #include "RootDlg.h"
  20. #include "NoRoot.h"
  21. #include "Request.h"
  22.  
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CHttpSvrView
  31.  
  32. IMPLEMENT_DYNCREATE(CHttpSvrView, CListView)
  33.  
  34. BEGIN_MESSAGE_MAP(CHttpSvrView, CListView)
  35.     //{{AFX_MSG_MAP(CHttpSvrView)
  36.     ON_COMMAND(IDM_VIEW_LARGE, OnViewLarge)
  37.     ON_UPDATE_COMMAND_UI(IDM_VIEW_LARGE, OnUpdateViewLarge)
  38.     ON_COMMAND(IDM_VIEW_LIST, OnViewList)
  39.     ON_UPDATE_COMMAND_UI(IDM_VIEW_LIST, OnUpdateViewList)
  40.     ON_COMMAND(IDM_VIEW_REPORT, OnViewReport)
  41.     ON_UPDATE_COMMAND_UI(IDM_VIEW_REPORT, OnUpdateViewReport)
  42.     ON_COMMAND(IDM_VIEW_SMALL, OnViewSmall)
  43.     ON_UPDATE_COMMAND_UI(IDM_VIEW_SMALL, OnUpdateViewSmall)
  44.     ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick)
  45.     ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnGetDispInfo)
  46.     ON_NOTIFY_REFLECT(LVN_DELETEITEM, OnDeleteItem)
  47.     ON_COMMAND(IDM_VIEW_CLEAR, OnViewClear)
  48.     //}}AFX_MSG_MAP
  49.     ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
  50.     ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
  51.     ON_COMMAND(IDM_POPUP_CLEAR, OnPopupClear)
  52.     ON_COMMAND(IDM_POPUP_EDIT, OnPopupEdit)
  53.     ON_COMMAND(IDM_POPUP_OPEN, OnPopupOpen)
  54. END_MESSAGE_MAP()
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CHttpSvrView construction/destruction
  58.  
  59. CHttpSvrView::CHttpSvrView()
  60. {
  61.     m_phdPopup = NULL;
  62. }
  63.  
  64. CHttpSvrView::~CHttpSvrView()
  65. {
  66. }
  67.  
  68. BOOL CHttpSvrView::PreCreateWindow(CREATESTRUCT& cs)
  69. {
  70.     cs.style = (cs.style & ~LVS_TYPEMASK) | LVS_REPORT;
  71.     cs.style |= LVS_AUTOARRANGE;
  72.     return CListView::PreCreateWindow(cs);
  73. }
  74.  
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CHttpSvrView drawing
  77.  
  78. void CHttpSvrView::OnDraw(CDC* pDC)
  79. {
  80.     CHttpSvrDoc* pDoc = GetDocument();
  81.     ASSERT_VALID(pDoc);
  82. }
  83.  
  84. void CHttpSvrView::OnInitialUpdate()
  85. {
  86.     CHttpSvrDoc* pDoc = GetDocument();
  87.     CListView::OnInitialUpdate();
  88.     // get the root directory....
  89.     CString strRoot = pDoc->m_strRoot;
  90.     // make sure it exists and it's a folder....
  91.     BOOL bLoop = TRUE;
  92.     while ( bLoop )
  93.     {
  94.         DWORD dwAttr = GetFileAttributes( strRoot );
  95.         if ( dwAttr == -1 )
  96.         {
  97.             CNoRootDlg dlg;
  98.             dlg.m_strRoot = strRoot;
  99.             UINT uButton = dlg.DoModal();
  100.             if ( uButton == IDOK )
  101.             {
  102.                 strRoot = dlg.m_strRoot;
  103.                 dwAttr = GetFileAttributes( strRoot );
  104.                 if ( dwAttr == -1 )
  105.                 {
  106.                     if ( !CreateDirectory( strRoot, NULL ) )
  107.                     {
  108.                         MessageBox( "Create Directory failed",
  109.                             strRoot, MB_ICONEXCLAMATION|MB_OK );
  110.                     }
  111.                 }
  112.             }
  113.             else // no....
  114.                 bLoop = FALSE; // use it anyway
  115.         }
  116.         else if ( (dwAttr & FILE_ATTRIBUTE_DIRECTORY) == 0 )
  117.         {
  118.             CBadRootDlg dlg;
  119.             dlg.m_strRoot = strRoot;
  120.             if ( dlg.DoModal() == IDCANCEL )
  121.                 bLoop = FALSE; // use it anyway
  122.         }
  123.         else
  124.         {
  125.             // root is okay, save it....
  126.             if ( strRoot.CompareNoCase(pDoc->m_strRoot) != 0 )
  127.             {
  128.                 pDoc->m_strRoot = strRoot;
  129.                 pDoc->SetModifiedFlag( TRUE );
  130.             }
  131.             bLoop = FALSE;  // okay!
  132.         }
  133.     }
  134. }
  135.  
  136. /////////////////////////////////////////////////////////////////////////////
  137. // CHttpSvrView diagnostics
  138.  
  139. #ifdef _DEBUG
  140. void CHttpSvrView::AssertValid() const
  141. {
  142.     CListView::AssertValid();
  143. }
  144.  
  145. void CHttpSvrView::Dump(CDumpContext& dc) const
  146. {
  147.     CListView::Dump(dc);
  148. }
  149.  
  150. CHttpSvrDoc* CHttpSvrView::GetDocument() // non-debug version is inline
  151. {
  152.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHttpSvrDoc)));
  153.     return (CHttpSvrDoc*)m_pDocument;
  154. }
  155. #endif //_DEBUG
  156.  
  157. /////////////////////////////////////////////////////////////////////////////
  158. // CHttpSvrView message handlers
  159.  
  160. BOOL CHttpSvrView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
  161. {
  162.     BOOL bCreated = CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  163.     if ( bCreated )
  164.     {
  165.         CListCtrl& listView = GetListCtrl();
  166.         int aWidths[] = { 150, 200, 50, 140, 225, 200 };
  167.         CString strHeading;
  168.  
  169.         for ( int iCol = 0; iCol < C_COLUMNS; iCol++) {
  170.             strHeading.LoadString( IDS_COLUMN1 + iCol );
  171.             listView.InsertColumn( iCol, strHeading, LVCFMT_LEFT,
  172.                 aWidths[iCol], iCol );
  173.         }
  174.  
  175.         // Create the full-sized and small icon image lists.
  176.         if ( m_ilLarge.Create( IDB_IMAGES, 32, 1, RGB(0,255,0) ) )
  177.         {
  178.             listView.SetImageList( &m_ilLarge, LVSIL_NORMAL );
  179.         }
  180.         if ( m_ilSmall.Create( IDB_SMALLIMAGES, 16, 1, RGB(0,255,0) ) )
  181.         {
  182.             listView.SetImageList( &m_ilSmall, LVSIL_SMALL);
  183.         }
  184.     }
  185.     return bCreated;
  186. }
  187.  
  188. void CHttpSvrView::SetListView( DWORD dwView )
  189. {
  190.     CListCtrl& list = GetListCtrl();
  191.     DWORD dwStyle = GetWindowLong( list.m_hWnd, GWL_STYLE );
  192.     if ( (dwStyle & LVS_TYPEMASK) != dwView )
  193.         SetWindowLong( list.m_hWnd, GWL_STYLE,
  194.             (dwStyle & ~LVS_TYPEMASK) | dwView );
  195. }
  196.  
  197. void CHttpSvrView::OnViewLarge()
  198. {
  199.     SetListView( LVS_ICON );
  200. }
  201.  
  202. void CHttpSvrView::OnUpdateViewLarge(CCmdUI* pCmdUI)
  203. {
  204.     CListCtrl& list = GetListCtrl();
  205.     DWORD dwStyle = GetWindowLong( list.m_hWnd, GWL_STYLE ) & LVS_TYPEMASK;
  206.     pCmdUI->SetCheck( dwStyle == LVS_ICON );
  207. }
  208.  
  209. void CHttpSvrView::OnViewList()
  210. {
  211.     SetListView( LVS_LIST );
  212. }
  213.  
  214. void CHttpSvrView::OnUpdateViewList(CCmdUI* pCmdUI)
  215. {
  216.     CListCtrl& list = GetListCtrl();
  217.     DWORD dwStyle = GetWindowLong( list.m_hWnd, GWL_STYLE ) & LVS_TYPEMASK;
  218.     pCmdUI->SetCheck( dwStyle == LVS_LIST );
  219. }
  220.  
  221. void CHttpSvrView::OnViewReport()
  222. {
  223.     SetListView( LVS_REPORT );
  224. }
  225.  
  226. void CHttpSvrView::OnUpdateViewReport(CCmdUI* pCmdUI)
  227. {
  228.     CListCtrl& list = GetListCtrl();
  229.     DWORD dwStyle = GetWindowLong( list.m_hWnd, GWL_STYLE ) & LVS_TYPEMASK;
  230.     pCmdUI->SetCheck( dwStyle == LVS_REPORT );
  231. }
  232.  
  233. void CHttpSvrView::OnViewSmall()
  234. {
  235.     SetListView( LVS_SMALLICON );
  236. }
  237.  
  238. void CHttpSvrView::OnUpdateViewSmall(CCmdUI* pCmdUI)
  239. {
  240.     CListCtrl& list = GetListCtrl();
  241.     DWORD dwStyle = GetWindowLong( list.m_hWnd, GWL_STYLE ) & LVS_TYPEMASK;
  242.     pCmdUI->SetCheck( dwStyle == LVS_SMALLICON );
  243. }
  244.  
  245. int CALLBACK
  246. CompareHitDocs( CHitDoc* doc1, CHitDoc* doc2, LPARAM lCol )
  247. {
  248.     int nCmp = 0;
  249.     switch( lCol )
  250.     {
  251.     case COLUMN_PATH:
  252.         nCmp = doc1->m_strFolder.CompareNoCase( doc2->m_strFolder );
  253.         break;
  254.     case COLUMN_HITS:
  255.         if ( doc1->m_nHits > doc2->m_nHits )
  256.             nCmp = -1;
  257.         else if ( doc1->m_nHits < doc2->m_nHits )
  258.             nCmp = 1;
  259.         break;
  260.     case COLUMN_LAST:
  261.         if ( doc1->m_timeLastHit > doc2->m_timeLastHit )
  262.             nCmp = -1;
  263.         else if ( doc1->m_timeLastHit < doc2->m_timeLastHit )
  264.             nCmp = 1;
  265.         break;
  266.     case COLUMN_CMD:
  267.         nCmp = doc1->m_strCommand.CompareNoCase( doc2->m_strCommand );
  268.         break;
  269.     case COLUMN_URL:
  270.         nCmp = doc1->m_strURL.CompareNoCase( doc2->m_strURL );
  271.         break;
  272.     default:
  273.         // put folders ahead of everything....
  274.         if ( doc1->m_bFolder && !doc2->m_bFolder )
  275.             nCmp = -1;
  276.         else if ( !doc1->m_bFolder && doc2->m_bFolder )
  277.             nCmp = 1;
  278.         // sort successfully hit docs....
  279.         else if ( doc1->m_nStatus == 200 && doc2->m_nStatus == 200 )
  280.         {
  281.             nCmp = doc1->m_strFile.CompareNoCase( doc2->m_strFile );
  282.             if ( nCmp == 0 )
  283.                 nCmp = doc1->m_strFolder.CompareNoCase( doc2->m_strFolder );
  284.         }
  285.         // put hit docs ahead of status items....
  286.         else if ( doc1->m_nStatus == 200 )
  287.             nCmp = -1;
  288.         else if ( doc2->m_nStatus == 200 )
  289.             nCmp = 1;
  290.         // sort status items by status value....
  291.         else if ( doc1->m_nStatus < doc2->m_nStatus )
  292.             nCmp = -1;
  293.         else if ( doc1->m_nStatus > doc2->m_nStatus )
  294.             nCmp = 1;
  295.         break;
  296.     }
  297.     return nCmp;
  298. }
  299.  
  300. void CHttpSvrView::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult)
  301. {
  302.     NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  303.     CListCtrl& list = GetListCtrl();
  304.     list.SortItems( (PFNLVCOMPARE)CompareHitDocs, pNMListView->iSubItem );
  305.     *pResult = 0;
  306. }
  307.  
  308. void CHttpSvrView::OnGetDispInfo(NMHDR* pNMHDR, LRESULT* pResult)
  309. {
  310.     LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
  311.     if ( pDispInfo->item.mask & LVIF_TEXT )
  312.     {
  313.         CHitDoc* pHitDoc = (CHitDoc*)(pDispInfo->item.lParam);
  314.         switch( pDispInfo->item.iSubItem )
  315.         {
  316.         case COLUMN_FILE:
  317.             lstrcpy( pDispInfo->item.pszText, pHitDoc->m_strFile );
  318.             break;
  319.         case COLUMN_PATH:
  320.             lstrcpy( pDispInfo->item.pszText, pHitDoc->m_strFolder );
  321.             break;
  322.         case COLUMN_HITS:
  323.             wsprintf( pDispInfo->item.pszText, "%d", pHitDoc->m_nHits );
  324.             break;
  325.         case COLUMN_LAST:
  326.             if ( pHitDoc->m_nHits > 0 )
  327.                 lstrcpy( pDispInfo->item.pszText, (pHitDoc->m_nHits)
  328.                     ? pHitDoc->m_timeLastHit.Format( IDS_TIMEFORMAT )
  329.                     : "" );
  330.             break;
  331.         case COLUMN_URL:
  332.             lstrcpy( pDispInfo->item.pszText, pHitDoc->m_strURL );
  333.             break;
  334.         case COLUMN_CMD:
  335.             lstrcpy( pDispInfo->item.pszText, pHitDoc->m_strCommand );
  336.             break;
  337.         }
  338.     }
  339.     *pResult = 0;
  340. }
  341.  
  342. void CHttpSvrView::OnDeleteItem(NMHDR* pNMHDR, LRESULT* pResult)
  343. {
  344.     NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  345.     CListCtrl& list = GetListCtrl();
  346.     LV_ITEM lvi;
  347.     lvi.mask = LVIF_PARAM;
  348.     lvi.iItem = pNMListView->iItem;
  349.     lvi.iSubItem = 0;
  350.     if ( list.GetItem( &lvi ) == TRUE )
  351.     {
  352.         CHitDoc* pHit = (CHitDoc*)(lvi.lParam);
  353.         delete pHit;
  354.     }
  355.     *pResult = 0;
  356. }
  357.  
  358. int
  359. CHttpSvrView::GetImage( CHitDoc* pHitDoc )
  360. {
  361.     // indexes into image maps for (status/100)....
  362.     int aStatImg[] = { 2, 5, 5, 4, 3, 3 };
  363.     int iImage;
  364.     if ( pHitDoc->m_nStatus != 0 && pHitDoc->m_nStatus != 200 )
  365.         iImage = aStatImg[ pHitDoc->m_nStatus/100]; // status image
  366.     else if ( pHitDoc->m_dwExecute )
  367.         iImage = 2; // CGI executables
  368.     else if ( pHitDoc->m_nHits == 0 )
  369.         iImage = 0; // no hits yet
  370.     else if ( pHitDoc->m_bFolder )
  371.         iImage = 1; // folder image
  372.     else
  373.         iImage = 0; // document
  374.  
  375.     return iImage;
  376. }
  377.  
  378. void CHttpSvrView::RegisterHit( CListCtrl& list, CRequest* pRequest )
  379. {
  380.     CHitDoc* pHitDoc = new CHitDoc( pRequest );
  381.     if ( pHitDoc )
  382.         InsertHitDoc( pHitDoc );
  383. }
  384.  
  385. void CHttpSvrView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
  386. {
  387.     if ( lHint == HINT_DOCHIT )
  388.     {
  389.         CRequest* pRequest = (CRequest*)pHint;
  390.         CListCtrl& list = GetListCtrl();
  391.         RegisterHit( list, pRequest );
  392.     }
  393. }
  394.  
  395. void CHttpSvrView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
  396. {
  397.     // Get the control....
  398.     CListCtrl& list = GetListCtrl();
  399.     int nSelected = list.GetSelectedCount();
  400.     // only proceed if one item selected....
  401.     if ( nSelected == 1 )
  402.     {
  403.         // find the selected item....
  404.         int ndx = 0;
  405.         int nItems = list.GetItemCount();
  406.         while ( ndx < nItems )
  407.         {
  408.             if ( list.GetItemState( ndx, LVIS_SELECTED ) == LVIS_SELECTED )
  409.             {
  410.                 LV_ITEM lvi;
  411.                 lvi.mask = LVIF_PARAM;
  412.                 lvi.iItem = ndx;
  413.                 lvi.iSubItem = 0;
  414.                 if ( list.GetItem( &lvi ) )
  415.                 {
  416.                     // only do something for OK and non-executable hits...
  417.                     CHitDoc* pHitDoc = (CHitDoc*)(lvi.lParam);
  418.                     if ( pHitDoc->m_nStatus == IDS_STATUS_OK &&
  419.                         pHitDoc->m_dwExecute == 0 )
  420.                     {
  421.                         ShellExecute( GetSafeHwnd(), "open",
  422.                             pHitDoc->m_strFile, NULL,
  423.                             pHitDoc->m_strFolder, SW_SHOW );
  424.                     }
  425.                 }
  426.                 break;
  427.             }
  428.             ++ndx;
  429.         }
  430.     }
  431.     *pResult = 0;
  432. }
  433.  
  434. void CHttpSvrView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult)
  435. {
  436.     // Get the control....
  437.     CListCtrl& list = GetListCtrl();
  438.     if ( list.GetSelectedCount() == 1 )
  439.     {
  440.         CPoint point;
  441.         if ( GetCursorPos( &point ) )
  442.             DoContextMenu( point );
  443.     }
  444.  
  445.     *pResult = 0;
  446. }
  447.  
  448. void CHttpSvrView::DoContextMenu( const CPoint& point )
  449. {
  450.     m_phdPopup = NULL;
  451.     // Get the control....
  452.     CListCtrl& list = GetListCtrl();
  453.     CPoint ptList = point;
  454.     list.ScreenToClient( &ptList );
  455.     int ndx = list.HitTest( ptList );
  456.     if ( ndx != -1 )
  457.     {
  458.         LV_ITEM lvi;
  459.         lvi.mask = LVIF_PARAM;
  460.         lvi.iItem = ndx;
  461.         lvi.iSubItem = 0;
  462.         if ( list.GetItem( &lvi ) )
  463.         {
  464.             CHitDoc* pHitDoc = (CHitDoc*)(lvi.lParam);
  465.             // get the popup menu type index....
  466.             int nType = 0;
  467.             if ( pHitDoc->m_dwExecute )
  468.                 nType = 1;
  469.             else if ( pHitDoc->m_nStatus != 200 )
  470.                 nType = 2;
  471.  
  472.             // load the menus....
  473.             CMenu menuPopups;
  474.             if ( menuPopups.LoadMenu( IDM_POPUPS ) )
  475.             {
  476.                 // get the popup....
  477.                 CMenu* pMenu = menuPopups.GetSubMenu( nType );
  478.                 if ( pMenu != NULL )
  479.                 {
  480.                     m_phdPopup = pHitDoc;
  481.                     pMenu->TrackPopupMenu( TPM_LEFTALIGN|TPM_RIGHTBUTTON,
  482.                         point.x, point.y, this );
  483.                 }
  484.             }
  485.         }
  486.     }
  487. }
  488.  
  489. void CHttpSvrView::OnPopupClear()
  490. {
  491.     if ( m_phdPopup != NULL )
  492.     {
  493.         // Get the control....
  494.         CListCtrl& list = GetListCtrl();
  495.         LV_FINDINFO lvfi;
  496.         lvfi.flags = LVFI_PARAM;
  497.         lvfi.lParam = (LPARAM)m_phdPopup;
  498.         int ndx = list.FindItem( &lvfi );
  499.         if ( ndx != -1 )
  500.             list.DeleteItem( ndx );
  501.     }
  502. }
  503.  
  504. void CHttpSvrView::OnPopupEdit()
  505. {
  506.     if ( m_phdPopup != NULL )
  507.     {
  508.         ShellExecute( GetSafeHwnd(), "edit",
  509.             m_phdPopup->m_strFile, NULL,
  510.             m_phdPopup->m_strFolder, SW_SHOW );
  511.     }
  512. }
  513.  
  514. void CHttpSvrView::OnPopupOpen()
  515. {
  516.     if ( m_phdPopup != NULL )
  517.     {
  518.         ShellExecute( GetSafeHwnd(), "open",
  519.             m_phdPopup->m_strFile, NULL,
  520.             m_phdPopup->m_strFolder, SW_SHOW );
  521.     }
  522. }
  523.  
  524. BOOL CHttpSvrView::InsertHitDoc( CHitDoc* pHitDoc )
  525. {
  526.     CListCtrl& list = GetListCtrl();
  527.     // look for a match on the file name....
  528.     LV_FINDINFO lvfi;
  529.     lvfi.flags = LVFI_STRING;
  530.     lvfi.psz = pHitDoc->m_strFile;
  531.     int ndx = list.FindItem( &lvfi );
  532.     while ( ndx != -1 )
  533.     {
  534.         // match found; see if folder matches....
  535.         CString strFolder = list.GetItemText( ndx, COLUMN_PATH );
  536.         if ( strFolder.CompareNoCase( pHitDoc->m_strFolder ) == 0 )
  537.         {
  538.             // matched; get the old HitDoc....
  539.             LV_ITEM lvi;
  540.             lvi.mask = LVIF_PARAM;
  541.             lvi.iItem = ndx;
  542.             lvi.iSubItem = 0;
  543.             if ( list.GetItem( &lvi ) )
  544.             {
  545.                 // get the old count
  546.                 CHitDoc* pOldHit = (CHitDoc*)(lvi.lParam);
  547.                 // add in the previous hits....
  548.                 pHitDoc->m_nHits += pOldHit->m_nHits;
  549.                 // delete the old hit....
  550.                 delete pOldHit;
  551.                 // update with new HitDoc....
  552.                 lvi.mask = LVIF_IMAGE|LVIF_PARAM;
  553.                 lvi.iImage = GetImage( pHitDoc );
  554.                 lvi.lParam = (LPARAM)pHitDoc;
  555.                 list.SetItem( &lvi );
  556.                 // indicate we've made changes....
  557.                 list.Update( lvi.iItem );
  558.                 break;
  559.             }
  560.         }
  561.         // get next item....
  562.         ndx = list.FindItem( &lvfi, ndx );
  563.     }
  564.     // if we didn't find anything....
  565.     if ( ndx == -1 )
  566.     {
  567.         // didn't find a match; add it to the list....
  568.         LV_ITEM lvi;
  569.         lvi.mask = LVIF_TEXT|LVIF_PARAM|LVIF_IMAGE;
  570.         lvi.iItem = 0;
  571.         lvi.iSubItem = 0;
  572.         lvi.pszText = LPSTR_TEXTCALLBACK;
  573.         lvi.lParam = (LPARAM)pHitDoc;
  574.         lvi.iImage = GetImage( pHitDoc );
  575.         if ( (ndx=list.InsertItem( &lvi )) != -1 )
  576.         {
  577.             // add all the callback sub items....
  578.             lvi.mask = LVIF_TEXT;
  579.             lvi.pszText = LPSTR_TEXTCALLBACK;
  580.             lvi.iItem = ndx;
  581.             for( int subNdx=1; subNdx < C_COLUMNS; ++subNdx )
  582.             {
  583.                 lvi.iSubItem = subNdx;
  584.                 list.SetItem( &lvi );
  585.             }
  586.         }
  587.         else
  588.         {
  589.             // insert failed; kill it....
  590.             delete pHitDoc;
  591.             pHitDoc = NULL;
  592.         }
  593.     }
  594.     return (pHitDoc != NULL);
  595. }
  596.  
  597. void CHttpSvrView::OnViewClear()
  598. {
  599.     CListCtrl& list = GetListCtrl();
  600.     list.DeleteAllItems();
  601. }
  602.