setclient.cpp
来自「监控开发资料,提供二次开发源码和使用说明书」· C++ 代码 · 共 312 行
CPP
312 行
// SetClient.cpp : implementation file
//
#include "stdafx.h"
#include "newclient.h"
#include "SetClient.h"
#include "SetClientRecordPlan.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSetClient dialog
extern HIKCLIENTPARAM hikClientParam;
extern void WriteClientConfig();
BOOL DeleteDirectory(LPCTSTR DirName);
int nUseCard;
CSetClient::CSetClient(CWnd* pParent /*=NULL*/)
: CDialog(CSetClient::IDD, pParent)
{
//{{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_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
}
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)
//}}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;
CNewclientApp* pApp = (CNewclientApp*)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 = hikClientParam.m_bCyclePlay;
if(m_bCyclePlay)
{
GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(TRUE);
}
else
{
GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(FALSE);
}
m_iCycleTime = hikClientParam.m_iCycleTime;
m_bUseCard = hikClientParam.m_bUseCard;
m_bAutoRecord = hikClientParam.m_bAutoRecord;
if(m_bAutoRecord)
GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(TRUE);
m_bCycleRecord = hikClientParam.m_bCycleRecord;
m_iFileInterVal = hikClientParam.m_iRecordFileInterval;
i = hikClientParam.m_iStartRecordDriver;
m_StartRecordDriverCtrl.SetCurSel(i);
j = hikClientParam.m_iEndRecordDriver;
m_StopRecordDriverCtrl.SetCurSel(j);
m_csLoadPath = hikClientParam.m_csDownLoadPath;
m_csPICPath = hikClientParam.m_csPictureSavePath;
m_csLogPath = hikClientParam.m_csLogSavePath;
m_bCheckServerTime = hikClientParam.m_bCheckServerTime;
CTime ctTime(2000, 1, 1, hikClientParam.m_iCheckServerTime/10000, (hikClientParam.m_iCheckServerTime%10000)/100, hikClientParam.m_iCheckServerTime%100);
m_ctCheckServerTime = ctTime;
if(m_bCheckServerTime)
{
GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(TRUE);
}
else
{
GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(FALSE);
}
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_csPICPath = Str;
UpdateData(FALSE);
}
}
void CSetClient::OnButselpicpath()
{
// TODO: Add your control notification handler code here
CString Str = F_GetDirectoryPath();
if(Str != "")
{
m_csLogPath = 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
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
if(m_CyclePlayCtrl.GetCheck() == 1)
{
GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(TRUE);
}
else
{
GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(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);
}
}
void CSetClient::OnClocalok()
{
// TODO: Add your control notification handler code here
int i, j;
UpdateData(TRUE);
if( (m_iFileInterVal < 1) || (m_iFileInterVal > 60) )
{
AfxMessageBox("非法的文件打包时间!");
return;
}
if( (m_csLoadPath == "") || (m_csPICPath == "") || (m_csLogPath == "") )
{
AfxMessageBox("请选择文件保存路径!");
return;
}
i = m_StartRecordDriverCtrl.GetCurSel();
j = m_StopRecordDriverCtrl.GetCurSel();
if(i > j)
{
AfxMessageBox("起始驱动器和终止驱动器不匹配!");
return;
}
if(m_iCycleTime < 20)
m_iCycleTime = 20;
hikClientParam.m_bCyclePlay = m_bCyclePlay;
hikClientParam.m_iCycleTime = m_iCycleTime;
if(hikClientParam.m_bUseCard != m_bUseCard)
{
if(!hikClientParam.m_bUseCard)
{
nUseCard = 1;
}
else
{
nUseCard = 2;
}
}
hikClientParam.m_bUseCard = m_bUseCard;
hikClientParam.m_bAutoRecord = m_bAutoRecord;
hikClientParam.m_bCycleRecord = m_bCycleRecord;
hikClientParam.m_iRecordFileInterval = m_iFileInterVal;
hikClientParam.m_iStartRecordDriver = i;
hikClientParam.m_iEndRecordDriver = j;
hikClientParam.m_csDownLoadPath = m_csLoadPath;
hikClientParam.m_csPictureSavePath = m_csPICPath;
hikClientParam.m_csLogSavePath = m_csLogPath;
hikClientParam.m_bCheckServerTime = m_bCheckServerTime;
hikClientParam.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();
}
void CSetClient::OnCancel()
{
// TODO: Add extra cleanup here
//CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?