home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / METAKIT.ZIP / EXAMPLES / DISCAT / DISCAT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-09  |  2.7 KB  |  100 lines

  1. //  discat.cpp  -  disk catalog sample code
  2. //
  3. //  This is a part of the MetaKit library.
  4. //  Copyright (c) 1996 Meta Four Software.
  5. //  All rights reserved.
  6. /////////////////////////////////////////////////////////////////////////////
  7.  
  8. #include "stdafx.h"
  9. #include "discat.h"
  10. #include "catalog.h"
  11.  
  12. CMyApp ThisApp;     // the global application object
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CMyApp
  16.  
  17. BOOL CMyApp::InitInstance()
  18. {
  19.     CMainDlgWindow mainDlg;
  20.     m_pMainWnd = &mainDlg;
  21.     mainDlg.DoModal();
  22.  
  23.     return FALSE;
  24. }
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMainDlgWindow
  28.  
  29. BEGIN_MESSAGE_MAP(CMainDlgWindow, CDialog)
  30.     //{{AFX_MSG_MAP(CMainDlgWindow)
  31.     ON_BN_CLICKED(IDC_SCAN_BTN, OnScanBtn)
  32.     //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34.  
  35. /////////////////////////////////////////////////////////////////////////////
  36.  
  37. CMainDlgWindow::CMainDlgWindow()
  38.     : CDialog (CMainDlgWindow::IDD)
  39. {
  40.     //{{AFX_DATA_INIT(CMainDlgWindow)
  41.     //}}AFX_DATA_INIT
  42. }
  43.  
  44. void CMainDlgWindow::DoDataExchange(CDataExchange* pDX)
  45. {
  46.     CDialog::DoDataExchange(pDX);
  47.     //{{AFX_DATA_MAP(CMainDlgWindow)
  48.     DDX_Control(pDX, IDC_PATH, m_path);
  49.     DDX_Control(pDX, IDC_STATUS, m_status);
  50.     //}}AFX_DATA_MAP
  51. }
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // [JCW]  This code added for MetaKit DISCAT
  55.  
  56. BOOL CMainDlgWindow::OnInitDialog() 
  57. {
  58.     CDialog::OnInitDialog();
  59.  
  60.         // use the application directory as the default scan path
  61.     CString appDir = ThisApp.m_pszHelpFilePath;
  62.     int n = appDir.ReverseFind('\\');
  63.     if (n >= 0)
  64.         m_path.SetWindowText(appDir.Left(n));
  65.     
  66.     return TRUE;  // return TRUE unless you set the focus to a control
  67. }
  68.  
  69. void CMainDlgWindow::OnScanBtn() 
  70. {
  71.         // find out which directory we should scan
  72.     CString path;
  73.     m_path.GetWindowText(path);
  74.     if (path.Right(1) == '\\')
  75.         path = path.Left(path.GetLength() - 1);
  76.  
  77.         // indicate what is going on
  78.     m_status.SetWindowText("Scanning, please wait...");
  79.  
  80.         // scan the directory tree, see CATALOG.CPP
  81.     c4_View dirs = fScanDirectories(path);
  82.     
  83.         // show what happened
  84.     char buf [30];
  85.     wsprintf(buf, "%d directories were scanned.", dirs.GetSize());
  86.     m_status.SetWindowText(buf);
  87.     
  88.         // save results to file
  89.     CFileDialog dlg (FALSE, NULL, "dirs");
  90.     if (dlg.DoModal() == IDOK)
  91.     {
  92.         c4_Storage storage (dlg.GetPathName(), true);
  93.         storage.Store("dirs", dirs);
  94.         storage.Commit();
  95.     }
  96. }  
  97.  
  98. /////////////////////////////////////////////////////////////////////////////
  99. // $Id: discat.cpp,v 1.2 1996/12/04 14:50:10 jcw Exp $
  100.