123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- // PicListDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "IDE.h"
- #include "PicListDlg.h"
- #include "Afxcoll.h"
- #include <io.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CPicListDlg dialog
- CPicListDlg::CPicListDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CPicListDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CPicListDlg)
- m_strPicName = _T("");
- //}}AFX_DATA_INIT
- }
- void CPicListDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CPicListDlg)
- DDX_LBString(pDX, IDC_LIST_PIC, m_strPicName);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CPicListDlg, CDialog)
- //{{AFX_MSG_MAP(CPicListDlg)
- ON_LBN_DBLCLK(IDC_LIST_PIC, OnDblclkListPic)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CPicListDlg message handlers
- BOOL CPicListDlg::DirSearch(CString strPath, CString strFileName)
- {
- BOOL bResult = FALSE;
- long hDir;
- struct _finddata_t fDir;
- int nDone;
- strPath += "*.*";
- hDir = _findfirst( (char *)(LPCTSTR)strPath, &fDir );
- if( -1L != hDir )
- {
- while( !( nDone = _findnext(hDir, &fDir) ) )
- {
- if( !strcmp(fDir.name, "..") ) continue;
- if( (_A_SUBDIR == fDir.attrib) )
- {
- CString str = fDir.name;
- if( !str.Compare(strFileName) )
- {
- bResult = TRUE;
- }
- }
- }
- }
- return bResult;
- }
- void CPicListDlg::FileSearch(CListBox* pList, CString strPath, CString strFileName, int nLayer)
- {
- long hfile;
- struct _finddata_t fFile;
- CString strCurr = strPath + "\\" + strFileName;
- int nDone=0;
- hfile = _findfirst( (char *)(LPCTSTR)strCurr, &fFile );
- if( -1L != hfile )
- {
- while( !( nDone = _findnext(hfile, &fFile) ) )
- {
- if( !strcmp(fFile.name,"..") ) continue;
- if( (_A_SUBDIR == fFile.attrib) )
- {
- strCurr = strPath + "\\" + fFile.name;
- CString str = fFile.name;
- FileSearch(pList, strCurr, "*.*", nLayer + 1);
- pList->AddString( str );
- }
- else
- {
- CString str = fFile.name;
- if( str.Right(4).Compare("view") ) continue;
- CString strTemp = str.Left(str.GetLength()-5);
- if( !DirSearch(strPath + "\\", strTemp ) )
- {
- pList->AddString( str.Left(str.GetLength()-5) );
- }
- }
- }
- _findclose(hfile);
- }
- }
- BOOL CPicListDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- CListBox* pList = (CListBox*)GetDlgItem(IDC_LIST_PIC);
-
- // ÉèÖûÃ浱ǰÎļþ¼Ð
- char picDir[128];
- strcpy(picDir, g_strDirectory);
- strcat(picDir, "\\");
- strcat(picDir, _PICTUREDIR);
- FileSearch( pList, CString(picDir), "*.*", 0 );
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CPicListDlg::OnDblclkListPic()
- {
- UpdateData(true);
- OnOK();
- }
- void CPicListDlg::OnOK()
- {
- CDialog::OnOK();
- }
|