home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / FERRAMEN / VBXSTD12 / FLISTDEM.CP_ / FLISTDEM.CPP
Encoding:
C/C++ Source or Header  |  1995-01-13  |  3.0 KB  |  116 lines

  1. // flistdem.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "vbxdemo.h"
  6. #include "flistdem.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CFlistDemo dialog
  15.  
  16.  
  17. CFlistDemo::CFlistDemo(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CFlistDemo::IDD, pParent)
  19. {
  20.     //{{AFX_DATA_INIT(CFlistDemo)
  21.     m_szDir = "";
  22.     m_szFile = "";
  23.     m_pDirList = NULL;
  24.     m_pFilesList = NULL;
  25.     //}}AFX_DATA_INIT
  26. }
  27.  
  28. void CFlistDemo::DoDataExchange(CDataExchange* pDX)
  29. {
  30.     CDialog::DoDataExchange(pDX);
  31.     //{{AFX_DATA_MAP(CFlistDemo)
  32.     DDX_VBText(pDX, IDC_TEXTDIR, 20, m_szDir);
  33.     DDX_VBText(pDX, IDC_TEXTFILE, 20, m_szFile);
  34.     DDX_VBFList(pDX, IDC_VBFLIST1, m_pDirList);
  35.     DDX_VBFList(pDX, IDC_VBFLIST2, m_pFilesList);
  36.     //}}AFX_DATA_MAP
  37. }
  38.  
  39. BEGIN_MESSAGE_MAP(CFlistDemo, CDialog)
  40.     //{{AFX_MSG_MAP(CFlistDemo)
  41.     ON_WM_DESTROY()
  42.     ON_BN_CLICKED(IDHELP, OnHelp)
  43.     ON_VBXEVENT(VBN_DBLCLICK, IDC_VBFLIST1, OnDblclickVbflist1)
  44.     ON_VBXEVENT(VBN_SELCHANGE, IDC_VBFLIST2, OnSelchangeVbflist2)
  45.     //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47.  
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CFlistDemo message handlers
  51.  
  52. void CFlistDemo::OnDestroy()
  53. {
  54.     CDialog::OnDestroy();
  55.     
  56.     ::WinHelp( m_hWnd, "VBXSTD12.HLP", HELP_QUIT, NULL );        
  57.     
  58. }
  59.  
  60. BOOL CFlistDemo::OnInitDialog()
  61. {   
  62. // ------------------------------------------------------------
  63. //    To select the current directory, use String Studio functions:
  64. //  1/ Count the number of slashs in the current directory,
  65. //    2/ Set the selection on this number,
  66. //    that' s all!
  67. // ------------------------------------------------------------
  68.  
  69.     CDialog::OnInitDialog();
  70. m_pDirList->SetSel2( )= 0L;
  71. m_szDir = m_pDirList->OutValue();
  72. m_pFilesList->SetSel2( )= 0L;
  73. m_szFile = m_pFilesList->ListString( 0 );
  74.  
  75. UpdateData( FALSE );    
  76. if ( !IsHlpHere() )
  77.         GetDlgItem( IDHELP )->EnableWindow( FALSE );
  78.     
  79.     return TRUE;  // return TRUE  unless you set the focus to a control
  80. }
  81.  
  82. void CFlistDemo::OnHelp()
  83. {
  84.     CString FAR szWinDir, szName, szMsg;
  85.     GetSystemDirectory( szWinDir.GetBuffer(250), 248 );
  86.     szWinDir.ReleaseBuffer();
  87.     if ( szWinDir.GetLength() > 3 )
  88.         szWinDir += "\\";
  89.     szName = szWinDir;
  90.     szName += "VBXSTD12.HLP";
  91.     if ( !IsHlpHere() )
  92.         return;
  93.     ::WinHelp( m_hWnd, szName, HELP_KEY, (long)"VBFList" );
  94. }
  95.  
  96. void CFlistDemo::OnDblclickVbflist1(UINT, int, CWnd*, LPVOID)
  97. {
  98.     m_szDir = (CString)m_pDirList->OutValue();
  99.     m_pFilesList->InValue() = (CString)m_pDirList->OutValue();
  100.     m_pFilesList->SetSel2() = 0L;
  101.     if ( m_pFilesList->ListCount( ) )
  102.         m_szFile = m_pFilesList->ListString( 0 );
  103.     else
  104.         m_szFile = "<None>";
  105.     UpdateData( FALSE );
  106. }
  107.  
  108. void CFlistDemo::OnSelchangeVbflist2(UINT, int, CWnd*, LPVOID lp)
  109. {
  110.     if ( m_pFilesList->ListCount( ) )
  111.         m_szFile = m_pFilesList->ListString( m_pFilesList->EventSelChangeID( lp ) );
  112.     else
  113.         m_szFile = "<None>";
  114.     UpdateData( FALSE );
  115. }
  116.