// SystemParaSetDlg.cpp : implementation file // #include "stdafx.h" #include "IDE.h" #include "SystemParaSetDlg.h" #include "Afxcoll.h" #include #include ".\systemparasetdlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSystemParaSetDlg dialog CSystemParaSetDlg::CSystemParaSetDlg(CWnd* pParent /*=NULL*/) : CDialog(CSystemParaSetDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSystemParaSetDlg) m_bAlarmVoice = FALSE; m_bHideTask = FALSE; m_strStartPic = _T(""); m_strStartPath = _T(""); m_bStartRun = FALSE; m_bEventAlarm = FALSE; //}}AFX_DATA_INIT } void CSystemParaSetDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSystemParaSetDlg) DDX_Check(pDX, IDC_ALARMVOICE, m_bAlarmVoice); DDX_Check(pDX, IDC_HIDETASK, m_bHideTask); DDX_CBString(pDX, IDC_STARTPIC, m_strStartPic); DDX_CBString(pDX, IDC_STARTPATH, m_strStartPath); DDX_Check(pDX, IDC_STARTRUN, m_bStartRun); DDX_Check(pDX, IDC_SYSALARM, m_bEventAlarm); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSystemParaSetDlg, CDialog) //{{AFX_MSG_MAP(CSystemParaSetDlg) //}}AFX_MSG_MAP ON_CBN_SELENDOK(IDC_STARTPIC, OnCbnSelendokStartpic) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSystemParaSetDlg message handlers BOOL CSystemParaSetDlg::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 CSystemParaSetDlg::FileSearch(CComboBox *pPicPath, CComboBox* pBox, 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(pPicPath, pBox, strCurr, "*.*", nLayer + 1); CString s1=str,s2=strPath; int nPos = s2.Find("\\\\"); if( nPos!=-1 ) { s2.Delete( nPos ); } int nLen = s2.GetLength(); nPos = s2.Find("View"); CString sTemp; if( nPosAddString( sTemp ); pPicPath->AddString( s2 ); } else { CString str = fFile.name; if( str.Right(4).Compare("view") ) continue; CString strTemp = str.Left(str.GetLength()-5); if( !DirSearch(strPath + "\\", strTemp ) ) { CString s1=str.Left(str.GetLength()-5),s2=strPath; int nPos = s2.Find("\\\\"); if( nPos!=-1 ) { s2.Delete( nPos ); } int nLen = s2.GetLength(); nPos = s2.Find("View"); CString sTemp; if( nPosAddString( sTemp ); pPicPath->AddString( s2 ); } } } _findclose(hfile); } } BOOL CSystemParaSetDlg::OnInitDialog() { CDialog::OnInitDialog(); CComboBox* pBox = (CComboBox*)GetDlgItem(IDC_STARTPIC); CComboBox* pPicPath = (CComboBox*)GetDlgItem(IDC_STARTPATH); char picDir[128] = {0}; strcpy(picDir, g_strDirectory); strcat(picDir, "\\"); strcat(picDir, _PICTUREDIR); FileSearch( pPicPath, pBox, CString(picDir), "*.*", 0 ); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CSystemParaSetDlg::OnCbnSelendokStartpic() { // TODO: 在此添加控件通知处理程序代码 int nSelectIndex = -1; CComboBox* pBox = (CComboBox*)GetDlgItem(IDC_STARTPIC); CComboBox* pPicPath = (CComboBox*)GetDlgItem(IDC_STARTPATH); nSelectIndex = pBox->GetCurSel(); pPicPath->SetCurSel(nSelectIndex); }