⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configrecord.cpp

📁 大华DVR的客户端开发包和Demo,从网上是下载不到的。
💻 CPP
字号:
// ConfigRecord.cpp : implementation file
//

#include "stdafx.h"
#include "netsdkdemo.h"
#include "ConfigRecord.h"
#include "NetSDKDemoDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CConfigRecord dialog


CConfigRecord::CConfigRecord(CWnd* pParent /*=NULL*/)
	: CDialog(CConfigRecord::IDD, pParent)
{
	//{{AFX_DATA_INIT(CConfigRecord)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_pDev = 0;;
	memset(m_recCFG, 0, 16*sizeof(DHDEV_RECORD_CFG));
	m_bInited = FALSE;
	m_chnIdx = -1;
	m_weekIdx = -1;
}


void CConfigRecord::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CConfigRecord)
	DDX_Control(pDX, IDC_CHECK_REDUNDANCY, m_redundancychk);
	DDX_Control(pDX, IDC_COMBO_RECORDWEEK, m_weeksel);
	DDX_Control(pDX, IDC_COMBO_CHANNO, m_channelsel);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CConfigRecord, CDialog)
	//{{AFX_MSG_MAP(CConfigRecord)
	ON_WM_SHOWWINDOW()
	ON_BN_CLICKED(IDC_UNDO_ALL, OnUndoAll)
	ON_BN_CLICKED(IDC_APPLY, OnApply)
	ON_CBN_SELCHANGE(IDC_COMBO_RECORDWEEK, OnSelchangeComboRecordweek)
	ON_CBN_SELCHANGE(IDC_COMBO_CHANNO, OnSelchangeComboChanno)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CConfigRecord message handlers

void CConfigRecord::GetConfig()
{
	if (!m_pDev || m_bInited)
	{
		return;
	}
	
	BOOL bRet = FALSE;
	DWORD retlen = 0;
	bRet = CLIENT_GetDevConfig(m_pDev->LoginID, DH_DEV_RECORDCFG, -1/*all channel*/,
		&m_recCFG, 16*sizeof(DHDEV_RECORD_CFG), &retlen);
	if (!bRet || retlen != m_pDev->Info.byChanNum*sizeof(DHDEV_RECORD_CFG))
	{
		((CNetSDKDemoDlg*)AfxGetMainWnd())->LastError();
		return;
	}
	else
	{
		m_bInited = TRUE;
	}
	
	//show config information
	if (m_channelsel.GetCount() > 0)
	{
		m_channelsel.SetCurSel(0);
		OnSelchangeComboChanno();
	}
}

void CConfigRecord::SetDevice(DeviceNode *pDev)
{
	m_pDev = pDev;
}

BOOL CConfigRecord::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	g_SetWndStaticText(this);
	if (!m_pDev)
	{
		return TRUE;
	}
	
	CString strChn;
	for (int i = 0; i < m_pDev->Info.byChanNum; i++)
	{
		strChn.Format("Channel_%d", i+1);
		m_channelsel.InsertString(i, strChn);
	}
	
	m_weeksel.InsertString(0,"Sunday");
	m_weeksel.InsertString(1,"Monday");
	m_weeksel.InsertString(2,"Tuesday");
	m_weeksel.InsertString(3,"Wedensday");
	m_weeksel.InsertString(4,"Thursday");
	m_weeksel.InsertString(5,"Friday");
	m_weeksel.InsertString(6,"Saturday");
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CConfigRecord::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	
	if (bShow)
	{
		GetConfig();
	}
}


void CConfigRecord::OnSelchangeComboChanno() 
{
	if (!m_bInited)
	{
		return;
	}
	
	int weekIdx;
	//store current config
	if (m_chnIdx < 0)
	{
		goto skipsave;
	}
	
	weekIdx = m_weeksel.GetCurSel();
	if (weekIdx < 0)
	{
		return;
	}
	
	m_recCFG[m_chnIdx].byPreRecordLen = GetDlgItemInt(IDC_EDIT_PRERECLEN);
	m_recCFG[m_chnIdx].byRedundancyEn = m_redundancychk.GetCheck();
	
	//show new config
skipsave:
	int chnIdx = m_channelsel.GetCurSel();
	if (chnIdx < 0)
	{
		return;
	}
	m_chnIdx = chnIdx;
	
	SetDlgItemInt(IDC_EDIT_PRERECLEN, m_recCFG[chnIdx].byPreRecordLen);
	m_redundancychk.SetCheck((m_recCFG[chnIdx].byRedundancyEn)?1:0);
	if (m_weeksel.GetCount())
	{
		m_weeksel.SetCurSel(0);
	}
	OnSelchangeComboRecordweek();
}

void CConfigRecord::OnSelchangeComboRecordweek() 
{
	if (!m_bInited || m_chnIdx < 0)
	{
		return;
	}
	
	//store current time sectors
	if (m_weekIdx >= 0)
	{
		int secIdx = 0;
		for (int i = 0; i < 6; i++)
		{
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byBeginHour = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byBeginMin = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byBeginSec = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
			
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byEndHour = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byEndMin = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byEndSec = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
		}
	}
	
	//show new time sectors
	int weekIdx = m_weeksel.GetCurSel();
	if (weekIdx < 0)
	{
		return;
	}
	m_weekIdx = weekIdx;
	
	int timeCtrlIdx = 0;
	for (int i = 0; i < 6; i++)
	{
		SetDlgItemInt(IDC_TIME_18+timeCtrlIdx, m_recCFG[m_chnIdx].stSect[weekIdx][i].byBeginHour);
		timeCtrlIdx++;
		SetDlgItemInt(IDC_TIME_18+timeCtrlIdx, m_recCFG[m_chnIdx].stSect[weekIdx][i].byBeginMin);
		timeCtrlIdx++;
		SetDlgItemInt(IDC_TIME_18+timeCtrlIdx, m_recCFG[m_chnIdx].stSect[weekIdx][i].byBeginSec);
		timeCtrlIdx++;

		SetDlgItemInt(IDC_TIME_18+timeCtrlIdx, m_recCFG[m_chnIdx].stSect[weekIdx][i].byEndHour);
		timeCtrlIdx++;
		SetDlgItemInt(IDC_TIME_18+timeCtrlIdx, m_recCFG[m_chnIdx].stSect[weekIdx][i].byEndMin);
		timeCtrlIdx++;
		SetDlgItemInt(IDC_TIME_18+timeCtrlIdx, m_recCFG[m_chnIdx].stSect[weekIdx][i].byEndSec);
		timeCtrlIdx++;
	}
}

void CConfigRecord::OnUndoAll() 
{
	m_bInited = FALSE;
	m_chnIdx = -1;
	m_weekIdx = -1;

	GetConfig();
}

void CConfigRecord::OnApply() 
{
	if (!m_bInited || m_chnIdx < 0)
	{
		return;
	}
	
	int weekIdx = m_weeksel.GetCurSel();
	if (weekIdx < 0)
	{
		return;
	}
	
	m_recCFG[m_chnIdx].byPreRecordLen = GetDlgItemInt(IDC_EDIT_PRERECLEN);
	m_recCFG[m_chnIdx].byRedundancyEn = m_redundancychk.GetCheck();

	if (m_weekIdx >= 0)
	{
		int secIdx = 0;
		for (int i = 0; i < 6; i++)
		{
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byBeginHour = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byBeginMin = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byBeginSec = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
			
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byEndHour = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byEndMin = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
			m_recCFG[m_chnIdx].stSect[m_weekIdx][i].byEndSec = GetDlgItemInt(IDC_TIME_18+secIdx);
			secIdx++;
		}
	}
	
	BOOL bRet = CLIENT_SetDevConfig(m_pDev->LoginID, DH_DEV_RECORDCFG, -1/*all channel*/,
								&m_recCFG, 16*sizeof(DHDEV_RECORD_CFG));
	if (!bRet)
	{
		((CNetSDKDemoDlg*)AfxGetMainWnd())->LastError();
		return;
	}
	else
	{
		MessageBox("Apply Success!", "OK");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -