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

📄 matrow.cpp

📁 SDK DVR/DVS HIKVISION
💻 CPP
字号:
// MatRow.cpp : implementation file
//

#include "stdafx.h"
#include "newclient.h"
#include "MatRow.h"

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

LONG g_lAmount = 0;
CMatRow *MatRow;
/////////////////////////////////////////////////////////////////////////////
// CMatRow dialog
void CALLBACK fRowDataCallBack(LONG lUserID, char *sIPAddr, LONG lRowAmout, char *pRecvDataBuffer,DWORD dwBufSize,DWORD dwUser)
{
// 	NET_DVR_MATRIX_ROW_ELEMENT stru;
// 	CString sTemp;
// 	if (lRowAmout <= 0)
// 	{
// 		AfxMessageBox("No Info.!");
// 		return;
// 	}
// 	if ((g_lAmount <= lRowAmout) && (lRowAmout > 0))
// 	{
// 		if (dwBufSize == sizeof(NET_DVR_MATRIX_ROW_ELEMENT))
// 		{
// 			memcpy(&stru, pRecvDataBuffer, dwBufSize);
// 			sTemp.Format("%d", stru.dwRowNum);
// 			MatRow->m_List.InsertItem(MatRow->m_iRowNum, sTemp, 0);
// 			sTemp.Format("%s", stru.sSurvChanName);
// 			MatRow->m_List.SetItemText(MatRow->m_iRowNum, 1, sTemp);
// 			sTemp.Format("%s", stru.struDecChanInfo.sDVRIP);
// 			MatRow->m_List.SetItemText(MatRow->m_iRowNum, 2, sTemp);
// 			sTemp.Format("%d", stru.struDecChanInfo.wDVRPort);
// 			MatRow->m_List.SetItemText(MatRow->m_iRowNum, 3, sTemp);
// 			sTemp.Format("%s", stru.struDecChanInfo.sUserName);
// 			MatRow->m_List.SetItemText(MatRow->m_iRowNum, 4, sTemp);
// 			sTemp.Format("%d", stru.struDecChanInfo.byChannel);
// 			MatRow->m_List.SetItemText(MatRow->m_iRowNum, 5, sTemp);
// 			if (stru.struDecChanInfo.byTransMode == 0)
// 			{
// 				sTemp.Format("%s", "Major");
// 			}
// 			else if (stru.struDecChanInfo.byTransMode == 1)
// 			{
// 				sTemp.Format("%s", "Minor");
// 			}			
// 			MatRow->m_List.SetItemText(MatRow->m_iRowNum, 6, sTemp);
// 			if (stru.struDecChanInfo.byTransProtocol == 0)
// 			{
// 				sTemp.Format("%s", "TCP");
// 			}
// 			else if (stru.struDecChanInfo.byTransProtocol == 1)
// 			{
// 				sTemp.Format("%s", "UDP");
// 			}	
// 			else if (stru.struDecChanInfo.byTransProtocol == 2)
// 			{
// 				sTemp.Format("%s", "MULTICAST");
// 			}
// 			MatRow->m_List.SetItemText(MatRow->m_iRowNum, 7, sTemp);
// 			MatRow->m_iRowNum++;
// 		}	
// 		g_lAmount++;
// 	}
// 	if (lRowAmout == g_lAmount)
// 	{
// 		AfxMessageBox("finish!");
// 	}
// 	
}

CMatRow::CMatRow(CWnd* pParent /*=NULL*/)
	: CDialog(CMatRow::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMatRow)
	m_UserPSW = _T("12345");
	m_UserName = _T("admin");
	m_Port = 8000;
	m_Ip = _T("192.0.1.139");
	m_ChanName = _T("test");
	m_RowNUM = 1;
	//}}AFX_DATA_INIT
}


void CMatRow::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMatRow)
	DDX_Control(pDX, IDC_COMBONUM, m_DecChanCtrl);
	DDX_Control(pDX, IDC_COMBOPROTYPE, m_TypeCtrl);
	DDX_Control(pDX, IDC_COMBOPROTOCOL, m_ProtocalCtrl);
	DDX_Control(pDX, IDC_COMCHAN, m_ChanCtrl);
	DDX_Control(pDX, IDC_LIST1, m_List);
	DDX_Text(pDX, IDC_EDITUSERPSW, m_UserPSW);
	DDX_Text(pDX, IDC_EDITUSERNAME, m_UserName);
	DDX_Text(pDX, IDC_EDITPORT, m_Port);
	DDX_Text(pDX, IDC_EDITIP, m_Ip);
	DDX_Text(pDX, IDC_EDITCHANNAME, m_ChanName);
	DDX_Text(pDX, IDC_EDITROWNUM, m_RowNUM);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMatRow, CDialog)
	//{{AFX_MSG_MAP(CMatRow)
	ON_BN_CLICKED(IDC_BUTDECSTART, OnButdecstart)
	ON_BN_CLICKED(IDC_BUTDECSTOP, OnButdecstop)
	ON_BN_CLICKED(IDC_BUTGETROW, OnButgetrow)
	ON_BN_CLICKED(IDC_BUTANO, OnButano)
	ON_BN_CLICKED(IDC_BUTAO, OnButao)
	ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
	ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnRclickList1)
	ON_BN_CLICKED(IDC_BUTDEL, OnButdel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMatRow message handlers

void CMatRow::OnCancel() 
{
	// TODO: Add extra cleanup here
	
//	CDialog::OnCancel();
}

void CMatRow::OnOK() 
{
	// TODO: Add extra validation here
	
//	CDialog::OnOK();
}

BOOL CMatRow::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString sTemp;
	m_nChanSel = 0;
	m_DecChanCtrl.ResetContent();	
	for(int i=0; i<m_iChannelnumber; i++)
	{
		sTemp.Format("channel %d", (m_lStartChan+i));
		m_DecChanCtrl.AddString(sTemp);
	}
	m_ChanCtrl.SetCurSel(1);
	m_DecChanCtrl.SetCurSel(m_nChanSel);
	m_TypeCtrl.SetCurSel(0);
	m_ProtocalCtrl.SetCurSel(0);

	m_List.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);

	m_List.InsertColumn(0, "Row Mark", LVCFMT_LEFT, 50, -1);
	m_List.InsertColumn(1, "Surv. Chan. Name", LVCFMT_LEFT, 120, -1);
	m_List.InsertColumn(2, "IP", LVCFMT_LEFT, 110, -1);
	m_List.InsertColumn(3, "Port", LVCFMT_LEFT, 50, -1);
	m_List.InsertColumn(4, "UserName", LVCFMT_LEFT, 120, -1);
	m_List.InsertColumn(5, "Channel", LVCFMT_LEFT, 50, -1);
	m_List.InsertColumn(6, "Mode", LVCFMT_LEFT, 70, -1);
	m_List.InsertColumn(7, "Protocol", LVCFMT_LEFT, 70, -1);
	m_iRowNum = 0;
	MatRow = this;
	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CMatRow::OnButdecstart() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
// 	NET_DVR_MATRIX_DYNAMIC_DEC stru;
// 	stru.dwSize = sizeof(NET_DVR_MATRIX_DYNAMIC_DEC);
// 
// 	stru.struDecChanInfo.byChannel = m_ChanCtrl.GetCurSel();
// 	stru.struDecChanInfo.byTransMode = m_TypeCtrl.GetCurSel();
// 	stru.struDecChanInfo.byTransProtocol = m_ProtocalCtrl.GetCurSel();	
// 	memcpy(stru.struDecChanInfo.sDVRIP, m_Ip, 16);
// 	memcpy(stru.struDecChanInfo.sPassword, m_UserPSW, PASSWD_LEN);
// 	memcpy(stru.struDecChanInfo.sUserName, m_UserName, NAME_LEN);
// 	stru.struDecChanInfo.wDVRPort = m_Port;
// 	if (!NET_DVR_MatrixStartDynamic(m_lServerID, m_DecChanCtrl.GetCurSel()+m_lStartChan, &stru))
// 	{
// 		CString sTemp;
// 		sTemp.Format("ERROR: NET_DVR_MatrixStartDynamic = %d \n", NET_DVR_GetLastError());
// 		TRACE(sTemp);
// 		//		return FALSE;
// 	}
}

void CMatRow::OnButdecstop() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

// 	if (!NET_DVR_MatrixStopDynamic(m_lServerID, m_DecChanCtrl.GetCurSel()+m_lStartChan))
// 	{
// 		CString sTemp;
// 		sTemp.Format("ERROR: NET_DVR_MatrixStopDynamic = %d \n", NET_DVR_GetLastError());
// 		TRACE(sTemp);
// 		//		return FALSE;
// 	}
// 	
}

void CMatRow::OnButgetrow() 
{
	// TODO: Add your control notification handler code here
	m_iRowNum = 0;
	g_lAmount = 0;
	m_List.DeleteAllItems();
//  	if (!NET_DVR_MatrixGetRowInfo(m_lServerID, fRowDataCallBack, 0))
//  	{
//  		CString sTemp;
//  		sTemp.Format("ERROR: NET_DVR_MatrixGetRowInfo = %d \n", NET_DVR_GetLastError());
//  		AfxMessageBox(sTemp);
//  		return;
//  	}
}

void CMatRow::OnButano() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
// 	NET_DVR_MATRIX_ROW_ELEMENT stru;
// 	stru.struDecChanInfo.byChannel = m_ChanCtrl.GetCurSel();
// 	stru.struDecChanInfo.byTransMode = m_TypeCtrl.GetCurSel();
// 	stru.struDecChanInfo.byTransProtocol = m_ProtocalCtrl.GetCurSel();
// 	memcpy(stru.sSurvChanName, m_ChanName, 128);
// 	memcpy(stru.struDecChanInfo.sDVRIP, m_Ip, 16);
// 	memcpy(stru.struDecChanInfo.sPassword, m_UserPSW, PASSWD_LEN);
// 	memcpy(stru.struDecChanInfo.sUserName, m_UserName, NAME_LEN);
// 	stru.struDecChanInfo.wDVRPort = m_Port;
// 	stru.dwRowNum = m_RowNUM;
//  	if (!NET_DVR_MatrixAddNoOverlayRowInfo(m_lServerID, 1, &stru))
//  	{
//  		CString sTemp;
//  		sTemp.Format("ERROR: NET_DVR_MatrixAddNoOverlayRowInfo = %d \n", NET_DVR_GetLastError());
//  		AfxMessageBox(sTemp);
//  		return;
//  	}
}

void CMatRow::OnButao() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
// 	NET_DVR_MATRIX_ROW_ELEMENT stru;
// 	stru.struDecChanInfo.byChannel = m_ChanCtrl.GetCurSel();
// 	stru.struDecChanInfo.byTransMode = m_TypeCtrl.GetCurSel();
// 	stru.struDecChanInfo.byTransProtocol = m_ProtocalCtrl.GetCurSel();
// 	memcpy(stru.sSurvChanName, m_ChanName, 128);
// 	memcpy(stru.struDecChanInfo.sDVRIP, m_Ip, 16);
// 	memcpy(stru.struDecChanInfo.sPassword, m_UserPSW, PASSWD_LEN);
// 	memcpy(stru.struDecChanInfo.sUserName, m_UserName, NAME_LEN);
// 	stru.struDecChanInfo.wDVRPort = m_Port;
// 	stru.dwRowNum = m_RowNUM;
//  	if (!NET_DVR_MatrixAddAndOverlayRowInfo(m_lServerID, 1, &stru))
//  	{
//  		CString sTemp;
//  		sTemp.Format("ERROR: NET_DVR_MatrixAddAndOverlayRowInfo = %d \n", NET_DVR_GetLastError());
//  		TRACE(sTemp);
//  		//		return FALSE;
//  	}
}

void CMatRow::OnButexit() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnOK();
}

void CMatRow::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

void CMatRow::OnButdel() 
{
	// TODO: Add your control notification handler code here
// 	POSITION  pos;
// 	int selpos = 0;
// 	CString csName;
// 	NET_DVR_MATRIX_ROW_INDEX stru;
// 	
// 	UpdateData(TRUE);
// 	pos = m_List.GetFirstSelectedItemPosition();
// 	if(pos == NULL)
// 	{
// 		AfxMessageBox("select certain row to delete!");
// 		return;
// 	}
// 	selpos = m_List.GetNextSelectedItem(pos);
// 	csName.Format("%s", m_List.GetItemText(selpos, 1));
// 	if(csName.IsEmpty())
// 		return;
// 	sprintf((char *)(stru.sSurvChanName), "%s", csName);
// 	csName.Format("%s", m_List.GetItemText(selpos, 0));
// 	stru.dwRowNum = atoi(csName);
// 	
//  	if (!NET_DVR_MatrixDelRowInfo(m_lServerID, 1, &stru))
//  	{
//  		CString sTemp;
//  		sTemp.Format("ERROR: NET_DVR_MatrixDelRowInfo = %d \n", NET_DVR_GetLastError());
//  		TRACE(sTemp);
//  		//		return FALSE;
//  	}
//  	else
//  	{
//  		m_iRowNum = 0;
//  		g_lAmount = 0;
//  		m_List.DeleteAllItems();
//  		if (!NET_DVR_MatrixGetRowInfo(m_lServerID, fRowDataCallBack, 0))
//  		{
//  			CString sTemp;
//  			sTemp.Format("ERROR: NET_DVR_MatrixGetRowInfo = %d \n", NET_DVR_GetLastError());
//  			TRACE(sTemp);
//  			//		return FALSE;
//  		}
//  	}
}

⌨️ 快捷键说明

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