SystemParaSetDlg.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. // SystemParaSetDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "IDE.h"
  5. #include "SystemParaSetDlg.h"
  6. #include "Afxcoll.h"
  7. #include <io.h>
  8. #include ".\systemparasetdlg.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CSystemParaSetDlg dialog
  16. CSystemParaSetDlg::CSystemParaSetDlg(CWnd* pParent /*=NULL*/)
  17. : CDialog(CSystemParaSetDlg::IDD, pParent)
  18. {
  19. //{{AFX_DATA_INIT(CSystemParaSetDlg)
  20. m_bAlarmVoice = FALSE;
  21. m_bHideTask = FALSE;
  22. m_strStartPic = _T("");
  23. m_strStartPath = _T("");
  24. m_bStartRun = FALSE;
  25. m_bEventAlarm = FALSE;
  26. //}}AFX_DATA_INIT
  27. }
  28. void CSystemParaSetDlg::DoDataExchange(CDataExchange* pDX)
  29. {
  30. CDialog::DoDataExchange(pDX);
  31. //{{AFX_DATA_MAP(CSystemParaSetDlg)
  32. DDX_Check(pDX, IDC_ALARMVOICE, m_bAlarmVoice);
  33. DDX_Check(pDX, IDC_HIDETASK, m_bHideTask);
  34. DDX_CBString(pDX, IDC_STARTPIC, m_strStartPic);
  35. DDX_CBString(pDX, IDC_STARTPATH, m_strStartPath);
  36. DDX_Check(pDX, IDC_STARTRUN, m_bStartRun);
  37. DDX_Check(pDX, IDC_SYSALARM, m_bEventAlarm);
  38. //}}AFX_DATA_MAP
  39. }
  40. BEGIN_MESSAGE_MAP(CSystemParaSetDlg, CDialog)
  41. //{{AFX_MSG_MAP(CSystemParaSetDlg)
  42. //}}AFX_MSG_MAP
  43. ON_CBN_SELENDOK(IDC_STARTPIC, OnCbnSelendokStartpic)
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CSystemParaSetDlg message handlers
  47. BOOL CSystemParaSetDlg::DirSearch(CString strPath, CString strFileName)
  48. {
  49. BOOL bResult = FALSE;
  50. long hDir;
  51. struct _finddata_t fDir;
  52. int nDone;
  53. strPath += "*.*";
  54. hDir = _findfirst( (char *)(LPCTSTR)strPath, &fDir );
  55. if( -1L != hDir )
  56. {
  57. while( !( nDone = _findnext(hDir, &fDir) ) )
  58. {
  59. if( !strcmp(fDir.name, "..") ) continue;
  60. if( (_A_SUBDIR == fDir.attrib) )
  61. {
  62. CString str = fDir.name;
  63. if( !str.Compare(strFileName) )
  64. {
  65. bResult = TRUE;
  66. }
  67. }
  68. }
  69. }
  70. return bResult;
  71. }
  72. void CSystemParaSetDlg::FileSearch(CComboBox *pPicPath, CComboBox* pBox, CString strPath, CString strFileName, int nLayer)
  73. {
  74. long hfile;
  75. struct _finddata_t fFile;
  76. CString strCurr = strPath + "\\" + strFileName;
  77. int nDone=0;
  78. hfile = _findfirst( (char *)(LPCTSTR)strCurr, &fFile );
  79. if( -1L != hfile )
  80. {
  81. while( !( nDone = _findnext(hfile, &fFile) ) )
  82. {
  83. if( !strcmp(fFile.name,"..") ) continue;
  84. if( (_A_SUBDIR == fFile.attrib) )
  85. {
  86. strCurr = strPath + "\\" + fFile.name;
  87. CString str = fFile.name;
  88. FileSearch(pPicPath, pBox, strCurr, "*.*", nLayer + 1);
  89. CString s1=str,s2=strPath;
  90. int nPos = s2.Find("\\\\");
  91. if( nPos!=-1 )
  92. {
  93. s2.Delete( nPos );
  94. }
  95. int nLen = s2.GetLength();
  96. nPos = s2.Find("View");
  97. CString sTemp;
  98. if( nPos<nLen-5 )
  99. sTemp = s2.Right( nLen-nPos-5 );
  100. if( sTemp!="" )
  101. sTemp = sTemp+"\\"+s1;
  102. else
  103. sTemp = s1;
  104. pBox->AddString( sTemp );
  105. pPicPath->AddString( s2 );
  106. }
  107. else
  108. {
  109. CString str = fFile.name;
  110. if( str.Right(4).Compare("view") ) continue;
  111. CString strTemp = str.Left(str.GetLength()-5);
  112. if( !DirSearch(strPath + "\\", strTemp ) )
  113. {
  114. CString s1=str.Left(str.GetLength()-5),s2=strPath;
  115. int nPos = s2.Find("\\\\");
  116. if( nPos!=-1 )
  117. {
  118. s2.Delete( nPos );
  119. }
  120. int nLen = s2.GetLength();
  121. nPos = s2.Find("View");
  122. CString sTemp;
  123. if( nPos<nLen-5 )
  124. sTemp = s2.Right( nLen-nPos-5 );
  125. if( sTemp!="" )
  126. sTemp = sTemp+"\\"+s1;
  127. else
  128. sTemp = s1;
  129. pBox->AddString( sTemp );
  130. pPicPath->AddString( s2 );
  131. }
  132. }
  133. }
  134. _findclose(hfile);
  135. }
  136. }
  137. BOOL CSystemParaSetDlg::OnInitDialog()
  138. {
  139. CDialog::OnInitDialog();
  140. CComboBox* pBox = (CComboBox*)GetDlgItem(IDC_STARTPIC);
  141. CComboBox* pPicPath = (CComboBox*)GetDlgItem(IDC_STARTPATH);
  142. char picDir[128] = {0};
  143. strcpy(picDir, g_strDirectory);
  144. strcat(picDir, "\\");
  145. strcat(picDir, _PICTUREDIR);
  146. FileSearch( pPicPath, pBox, CString(picDir), "*.*", 0 );
  147. return TRUE; // return TRUE unless you set the focus to a control
  148. // EXCEPTION: OCX Property Pages should return FALSE
  149. }
  150. void CSystemParaSetDlg::OnCbnSelendokStartpic()
  151. {
  152. // TODO: 在此添加控件通知处理程序代码
  153. int nSelectIndex = -1;
  154. CComboBox* pBox = (CComboBox*)GetDlgItem(IDC_STARTPIC);
  155. CComboBox* pPicPath = (CComboBox*)GetDlgItem(IDC_STARTPATH);
  156. nSelectIndex = pBox->GetCurSel();
  157. pPicPath->SetCurSel(nSelectIndex);
  158. }