// SetClient.cpp : implementation file // #include "stdafx.h" #include "StoneU_HC_OCX.h" #include "SetClient.h" #include "SetClientRecordPlan.h" #include "Global.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSetClient dialog extern CLIENTPARAM ClientParam; extern void WriteClientConfig(); BOOL DeleteDirectory(LPCTSTR DirName); int nUseCard; CSetClient::CSetClient(CWnd* pParent /*=NULL*/) : CDialog(CSetClient::IDD, pParent) , m_nComb_VideoMaxTime(0) , m_nComb_NoMotionTime(0) { //{{AFX_DATA_INIT(CSetClient) m_bAutoRecord = FALSE; m_bCyclePlay = FALSE; m_bCycleRecord = FALSE; m_bUseCard = FALSE; m_iCycleTime = 0; m_iFileInterVal = 0; m_csLoadPath = _T(""); m_csLogPath = _T(""); m_csPICPath = _T(""); m_ctCheckServerTime = 0; m_bCheckServerTime = FALSE; //}}AFX_DATA_INIT } void CSetClient::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSetClient) DDX_Control(pDX, IDC_COMBOVIDEOFORMAT, m_VideoFormatCombo); DDX_Control(pDX, IDC_COMBO2, m_StopRecordDriverCtrl); DDX_Control(pDX, IDC_COMBO1, m_StartRecordDriverCtrl); DDX_Control(pDX, IDC_CHKUSECARD, m_UseCardCtrl); DDX_Control(pDX, IDC_CHKCYCLERECORD, m_CycleRecordCtrl); DDX_Control(pDX, IDC_CHKCYCLEPLAY, m_CyclePlayCtrl); DDX_Control(pDX, IDC_CHKAUTORECORD, m_AutoRecordCtrl); DDX_Check(pDX, IDC_CHKAUTORECORD, m_bAutoRecord); DDX_Check(pDX, IDC_CHKCYCLEPLAY, m_bCyclePlay); DDX_Check(pDX, IDC_CHKCYCLERECORD, m_bCycleRecord); DDX_Check(pDX, IDC_CHKUSECARD, m_bUseCard); DDX_Text(pDX, IDC_EDITCYCLETIME, m_iCycleTime); DDX_Text(pDX, IDC_EDITFILEINTERVAL, m_iFileInterVal); DDX_Text(pDX, IDC_EDITLOADPATH, m_csLoadPath); DDX_Text(pDX, IDC_EDITLOGPATH, m_csLogPath); DDX_Text(pDX, IDC_EDITPICPATH, m_csPICPath); DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER, m_ctCheckServerTime); DDX_Check(pDX, IDC_CHECKSYSTIME, m_bCheckServerTime); //}}AFX_DATA_MAP DDX_CBIndex(pDX, IDC_COMBO_VIDEOMAXTIME, m_nComb_VideoMaxTime); DDX_CBIndex(pDX, IDC_COMBO_NOMOTIONTIME, m_nComb_NoMotionTime); DDX_Control(pDX, IDC_COMBO_VIDEOMAXTIME, m_Comb_VideoMaxTime); DDX_Control(pDX, IDC_COMBO_NOMOTIONTIME, m_Comb_NoMotionTime); } BEGIN_MESSAGE_MAP(CSetClient, CDialog) //{{AFX_MSG_MAP(CSetClient) ON_BN_CLICKED(IDC_BUTSELFILEPATH, OnButselfilepath) ON_BN_CLICKED(IDC_BUTSELLOGPATH, OnButsellogpath) ON_BN_CLICKED(IDC_BUTSELPICPATH, OnButselpicpath) ON_BN_CLICKED(IDC_BUTTONSETTIME, OnButtonsettime) ON_BN_CLICKED(IDC_CHKAUTORECORD, OnChkautorecord) ON_BN_CLICKED(IDC_CHKCYCLEPLAY, OnChkcycleplay) ON_BN_CLICKED(IDC_CHECKSYSTIME, OnChecksystime) ON_BN_CLICKED(IDCLOCALOK, OnClocalok) ON_BN_CLICKED(IDC_CHKUSECARD, OnChkusecard) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSetClient message handlers BOOL CSetClient::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here int i, j; CRect rc(0, 0, 0, 0); GetParent()->GetClientRect(&rc); ((CTabCtrl*)GetParent())->AdjustRect(FALSE, &rc); MoveWindow(&rc); CString csHardDriver; CStoneU_HC_OCXApp* pApp = (CStoneU_HC_OCXApp*)AfxGetApp(); for(i = 0; i < (int)(pApp->m_iDriverNum); i++) { csHardDriver.Format("%c%s", pApp->m_cHardDriver[i], ":\\"); m_StartRecordDriverCtrl.AddString(csHardDriver); m_StopRecordDriverCtrl.AddString(csHardDriver); } m_bCyclePlay = ClientParam.m_bCyclePlay; if(m_bCyclePlay) { GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(TRUE); } else { GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(FALSE); } m_iCycleTime = ClientParam.m_iCycleTime; m_bUseCard = ClientParam.m_bUseCard; m_VideoFormatCombo.SetCurSel(ClientParam.m_bNTSC); UpdateData(FALSE); OnChkusecard(); m_bAutoRecord = ClientParam.m_bAutoRecord; if(m_bAutoRecord) GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(TRUE); m_bCycleRecord = ClientParam.m_bCycleRecord; m_iFileInterVal = ClientParam.m_iRecordFileInterval; i = ClientParam.m_iStartRecordDriver; m_StartRecordDriverCtrl.SetCurSel(i); j = ClientParam.m_iEndRecordDriver; m_StopRecordDriverCtrl.SetCurSel(j); m_csLoadPath = ClientParam.m_csDownLoadPath; m_csPICPath = ClientParam.m_csPictureSavePath; m_csLogPath = ClientParam.m_csLogSavePath; m_bCheckServerTime = ClientParam.m_bCheckServerTime; CTime ctTime(2000, 1, 1, ClientParam.m_iCheckServerTime/10000, (ClientParam.m_iCheckServerTime%10000)/100, ClientParam.m_iCheckServerTime%100); m_ctCheckServerTime = ctTime; if(m_bCheckServerTime) { GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(TRUE); } else { GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(FALSE); } UpdateData(FALSE); m_Comb_VideoMaxTime.InsertString(0,"3分钟" ); m_Comb_VideoMaxTime.InsertString(1,"5分钟"); m_Comb_VideoMaxTime.InsertString(2,"10分钟"); m_Comb_VideoMaxTime.InsertString(3,"20分钟"); m_Comb_VideoMaxTime.InsertString(4,"30分钟"); m_Comb_VideoMaxTime.InsertString(5,"1小时"); m_Comb_VideoMaxTime.SetCurSel(0); m_Comb_NoMotionTime.InsertString(0,"30秒" ); m_Comb_NoMotionTime.InsertString(1,"1分钟"); m_Comb_NoMotionTime.InsertString(2,"3分钟"); m_Comb_NoMotionTime.InsertString(3,"5分钟"); m_Comb_NoMotionTime.SetCurSel(0); m_nComb_VideoMaxTime = g_nVideoMaxTime; m_nComb_NoMotionTime = g_nNoMotionTime; UpdateData( false ); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CSetClient::OnButselfilepath() { // TODO: Add your control notification handler code here CString Str = F_GetDirectoryPath(); if(Str != "") { m_csLoadPath = Str; UpdateData(FALSE); } } void CSetClient::OnButsellogpath() { // TODO: Add your control notification handler code here CString Str = F_GetDirectoryPath(); if(Str != "") { m_csLogPath = Str; UpdateData(FALSE); } } void CSetClient::OnButselpicpath() { // TODO: Add your control notification handler code here CString Str = F_GetDirectoryPath(); if(Str != "") { m_csPICPath = Str; UpdateData(FALSE); } } void CSetClient::OnButtonsettime() { // TODO: Add your control notification handler code here CSetClientRecordPlan SetClientRecordPlanDlg; SetClientRecordPlanDlg.DoModal(); } void CSetClient::OnChkautorecord() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(m_AutoRecordCtrl.GetCheck() == 1) GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(FALSE); } CString CSetClient::F_GetDirectoryPath() { LPITEMIDLIST pidlRoot=NULL; SHGetSpecialFolderLocation(m_hWnd,CSIDL_DRIVES,&pidlRoot); BROWSEINFO bi; //必须传入的参数,下面就是这个结构的参数的初始化 CString strDisplayName; //用来得到,你选择的活页夹路径,相当于提供一个缓冲区 bi.hwndOwner=GetSafeHwnd(); //得到父窗口Handle值 bi.pidlRoot=pidlRoot; //这个变量就是我们在上面得到的. bi.pszDisplayName=strDisplayName.GetBuffer(MAX_PATH+1); //得到缓冲区指针 bi.lpszTitle="文件夹"; //设置标题 bi.ulFlags=BIF_RETURNONLYFSDIRS; //设置标志 bi.lpfn=NULL; bi.lParam=0; bi.iImage=0; //上面这个是一些无关的参数的设置,最好设置起来, LPITEMIDLIST lpIDList= SHBrowseForFolder(&bi); //打开对话框 strDisplayName.ReleaseBuffer(); //和上面的GetBuffer()相对应 char pPath[MAX_PATH]; CString Str; if(lpIDList) { SHGetPathFromIDList (lpIDList, pPath); Str=pPath; } return Str; } void CSetClient::OnChkcycleplay() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(m_CyclePlayCtrl.GetCheck() == 1) { GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(TRUE); } else { GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(FALSE); } UpdateData(FALSE); } void CSetClient::OnChecksystime() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(m_bCheckServerTime) { GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(TRUE); } else { GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(FALSE); } UpdateData(FALSE); } void CSetClient::OnClocalok() { // TODO: Add your control notification handler code here int i, j; UpdateData(TRUE); if( (m_iFileInterVal < 1) || (m_iFileInterVal > 60) ) { MessageBox("非法的文件打包时间!", "温馨提示", MB_ICONINFORMATION); return; } if( (m_csLoadPath == "") || (m_csPICPath == "") || (m_csLogPath == "") ) { MessageBox("请选择文件保存路径!", "温馨提示", MB_ICONINFORMATION); return; } i = m_StartRecordDriverCtrl.GetCurSel(); j = m_StopRecordDriverCtrl.GetCurSel(); if(i > j) { MessageBox("起始驱动器和终止驱动器不匹配!", "温馨提示", MB_ICONINFORMATION); return; } if(m_iCycleTime < 5) m_iCycleTime = 5; ClientParam.m_bCyclePlay = m_bCyclePlay; ClientParam.m_iCycleTime = m_iCycleTime; if(ClientParam.m_bUseCard != m_bUseCard) { if(!ClientParam.m_bUseCard) { nUseCard = 1; } else { nUseCard = 2; } } ClientParam.m_bUseCard = m_bUseCard; ClientParam.m_bNTSC = m_VideoFormatCombo.GetCurSel(); ClientParam.m_bAutoRecord = m_bAutoRecord; ClientParam.m_bCycleRecord = m_bCycleRecord; ClientParam.m_iRecordFileInterval = m_iFileInterVal; ClientParam.m_iStartRecordDriver = i; ClientParam.m_iEndRecordDriver = j; ClientParam.m_csDownLoadPath = m_csLoadPath; ClientParam.m_csPictureSavePath = m_csPICPath; ClientParam.m_csLogSavePath = m_csLogPath; ClientParam.m_bCheckServerTime = m_bCheckServerTime; ClientParam.m_iCheckServerTime = m_ctCheckServerTime.GetHour()*10000 + m_ctCheckServerTime.GetMinute()*100 + m_ctCheckServerTime.GetSecond(); CreateDirectory(m_csLoadPath, NULL); CreateDirectory(m_csPICPath, NULL); CreateDirectory(m_csLogPath, NULL); WriteClientConfig(); UpdateData(); //g_strVideoPath = m_sEdit_VideoPath; //g_nDiskVolume = m_nComb_Velume; //g_nOperateType = m_nComb_OperateType; g_nVideoMaxTime = m_nComb_VideoMaxTime; g_nNoMotionTime = m_nComb_NoMotionTime; //g_IniFile.SetVarStr(_T("video"),_T("VideoPath"),g_strVideoPath); //g_IniFile.SetVarInt(_T("video"),_T("DiskVelume"),g_nDiskVolume); //g_IniFile.SetVarInt(_T("video"),_T("OperateType"),g_nOperateType); g_IniFile.SetVarInt(_T("video"),_T("VideoMaxTime"),g_nVideoMaxTime); g_IniFile.SetVarInt(_T("video"),_T("NoMotionTime"),g_nNoMotionTime); //if (!SetCurrentDirectory(g_strVideoPath)) // CreateDirectory(g_strVideoPath, NULL); } void CSetClient::OnCancel() { // TODO: Add extra cleanup here //CDialog::OnCancel(); } void CSetClient::OnChkusecard() { // TODO: Add your control notification handler code here UpdateData(TRUE); if (m_bUseCard) { GetDlgItem(IDC_COMBOVIDEOFORMAT)->EnableWindow(TRUE); } else { GetDlgItem(IDC_COMBOVIDEOFORMAT)->EnableWindow(FALSE); } UpdateData(FALSE); }