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

📄 netsdkdemo.cpp

📁 用大华sdk
💻 CPP
📖 第 1 页 / 共 2 页
字号:
				break;
			case 9:
				//main->m_dlgVod.SelFile(1);
				main->ShowVod(button);
				break;
			case 10:
				main->SelectNext(1,1,0);
				break;
			case 11:		//焦距
				main->PtzZoomTele();
				break;
			case 12:		//云台
				main->PtzRight();
				break;
			}
			break;
		case 17:		//确认,只对Dvr,通道和回放有效
			main->Flash(10);
			long r;
			switch(m_ir_fn)
			{
			case 0:
				//if (m_OnOff) ShutDown();			//按了开关然后按确认并且按开关次数是偶数则关闭电脑.2006/102/18
			case 7:
				{
					main->OnDblclkTreeDevicelist(NULL,&r);
					break;
				}
			case 9:
				main->ShowVod(button);
				break;
			case 10:
				main->OnDblclkTreeDevicelist(NULL,&r);
				main->ZoomSwitch();
				//main->m_dlgDvr.ZoomIn();	//通道单屏/多屏
				break;
			}
			break;
			

	}
//	m_lst_btn.InsertItem(7,"Dvr");
//	m_lst_btn.InsertItem(8,"聚焦");
//	m_lst_btn.InsertItem(9,"回放");
//	m_lst_btn.InsertItem(10,"通道");
//	m_lst_btn.InsertItem(11,"焦距");
//	m_lst_btn.InsertItem(12,"云台");
//	m_lst_btn.InsertItem(13,"上");
//	m_lst_btn.InsertItem(14,"下");
//	m_lst_btn.InsertItem(15,"左");
//	m_lst_btn.InsertItem(16,"右");
//	m_lst_btn.InsertItem(17,"确认");
	
}
/*=================================================================
  功  能: 选择Dvr树的dvr节点
  参  数: int Dvr;0表示选择Dvr节点,1表示选择通道节点
  返回值: 无
  备  注: 
  作  者:    刘海
  更  新:   1.0 2006/10/3
=================================================================*/
void CNetSDKDemoApp::SelDvr(int Dvr)
{
	/*
	CDvrClientDemoDlg* main=(CDvrClientDemoDlg*)theApp.m_pMainWnd;
	int img,sel_img;
	img=main->m_tabCtrl.GetCurSel();
	if (img!=0) main->m_tabCtrl.SetCurFocus(0);		//首先激活tab页
	HTREEITEM hitem=main->m_dlgDvr.m_treeDevice.GetSelectedItem();
	if (hitem!=NULL)
	{
		main->m_dlgDvr.m_treeDevice.GetItemImage(hitem,img,sel_img);
		if (Dvr==0)
			{if (img>1) main->m_dlgDvr.m_treeDevice.SelectItem(main->m_dlgDvr.m_treeDevice.GetParentItem(hitem));}		//选择dvr
		else
			if (img<2 && (main->m_dlgDvr.m_treeDevice.GetChildItem(hitem)!=NULL) )
			{
				main->m_dlgDvr.m_treeDevice.SelectItem(main->m_dlgDvr.m_treeDevice.GetChildItem(hitem) );
				main->m_dlgDvr.SetCurSel(0);
				//选择通道设置选择状态
			}
	}
	else
	{
		main->m_dlgDvr.m_treeDevice.SelectItem(main->m_dlgDvr.m_treeDevice.GetRootItem());
		hitem=main->m_dlgDvr.m_treeDevice.GetSelectedItem();
		if (Dvr==1 && hitem!=NULL && (main->m_dlgDvr.m_treeDevice.GetChildItem(hitem)!=NULL) )
		{
			main->m_dlgDvr.m_treeDevice.SelectItem(main->m_dlgDvr.m_treeDevice.GetChildItem(hitem) );
			main->m_dlgDvr.SetCurSel(0);
		}
	}
	*/
}
//new
//自定义全局函数
void g_systimetodhtime(SYSTEMTIME *systime , NET_TIME *dhtime)
{
	dhtime->dwYear = (DWORD)systime->wYear;
	dhtime->dwMonth = (DWORD)systime->wMonth;
	dhtime->dwDay = (DWORD)systime->wDay;
	dhtime->dwHour = (DWORD)systime->wHour;
	dhtime->dwMinute = (DWORD)systime->wMinute;
	dhtime->dwSecond = (DWORD)systime->wSecond;
}

//自定义全局函数
void g_dhtimetosystime(NET_TIME *dhtime , SYSTEMTIME *systime)
{
	systime->wYear = (WORD)dhtime->dwYear;
	systime->wMonth = (WORD)dhtime->dwMonth;
	systime->wDay = (WORD)dhtime->dwDay;
	systime->wHour = (WORD)dhtime->dwHour;
	systime->wMinute = (WORD)dhtime->dwMinute;
	systime->wSecond = (WORD)dhtime->dwSecond;
}

//自定义全局函数
CString g_TimeOutString(NET_TIME *dhtime )
{
	CString nStr;

	nStr.Format("%04d-%02d-%02d %02d:%02d:%02d", dhtime->dwYear,dhtime->dwMonth,dhtime->dwDay,
		dhtime->dwHour, dhtime->dwMinute, dhtime->dwSecond);

	return nStr;
}

//自定义全局函数
DWORD g_IntervalTime(NET_TIME *stime, NET_TIME *etime )
{
	if(*((DWORD *)&stime) > *((DWORD *)&etime))
	{
		return 0;
	}

	//只处理最多相隔一天的两时间差,大于一天做一天计
	DWORD sSec = stime->dwHour * 3600 + stime->dwMinute *60 + stime->dwSecond;
	DWORD eSec = etime->dwHour * 3600 + etime->dwMinute *60 + etime->dwSecond;

	if(sSec > eSec)
	{
		sSec += 3600 * 24;
	}
	return (eSec - sSec);
}

//“英文字符串”转换为“当前语言类型的字符串”
CString ConvertString(CString strText)
{
	char *val = new char[200];
	CString strIniPath,strRet;

	memset(val,0,200);
	GetPrivateProfileString("String",strText,"",
		val,200,"./langchn.ini");
	strRet = val;
	if(strRet.GetLength()==0)
	{
		//如果ini文件中不存在对应的字符串,设置为默认值(英文)
		strRet=strText;
	}
	delete val;
	return strRet;
}
//设置对话框中的静态文本(英文-->当前语言)   
void g_SetWndStaticText(CWnd * pWnd)
{
	CString strCaption,strText;

	//设置主窗口的标题
	pWnd->GetWindowText(strCaption);
	if(strCaption.GetLength()>0)
	{
		strText=ConvertString(strCaption);
		pWnd->SetWindowText(strText);
	}

	//设置子窗口的标题
	CWnd * pChild=pWnd->GetWindow(GW_CHILD);
	CString strClassName;
	while(pChild)
	{
		//////////////////////////////////////////////////////////////////////////		
		//Added by Jackbin 2005-03-11
		strClassName = ((CRuntimeClass*)pChild->GetRuntimeClass())->m_lpszClassName;
		if(strClassName == "CEdit")
		{
			//下一个子窗口
			pChild=pChild->GetWindow(GW_HWNDNEXT);
			continue;
		}

		//////////////////////////////////////////////////////////////////////////	

		//设置子窗口的当前语言文本
		pChild->GetWindowText(strCaption);
		strText=ConvertString(strCaption);
		pChild->SetWindowText(strText);

		//下一个子窗口
		pChild=pChild->GetWindow(GW_HWNDNEXT);
	}
}

int CNetSDKDemoApp::ExitInstance() 
{
//	DeleteCriticalSection(&g_cs);
	return CWinApp::ExitInstance();
}

void OnReceiveData(LPVOID pSender,void* pBuf,DWORD InBufferCount)
{
	PBYTE p=(PBYTE)pBuf;
	bool b=true;
	if (InBufferCount<3) return;
	if (p[InBufferCount-1]==255 && p[InBufferCount-2]==255) return;		//ff ff 的侦丢掉,防止连码。2006/10/7
	if (theApp.m_learn)
	{		//学习状态
		theApp.m_learn_data[theApp.m_learn_count].RemoveAll();
		for (DWORD i=0;i<InBufferCount;i++)
			theApp.m_learn_data[theApp.m_learn_count].Add(p[i]);
	/*if (theApp.m_learn_count>0)
		{
			if (theApp.m_learn_data[theApp.m_learn_count].GetSize() ==theApp.m_learn_data[theApp.m_learn_count-1].GetSize())
			{
				for (int i=0;i<theApp.m_learn_data[theApp.m_learn_count].GetSize();i++)
					if (theApp.m_learn_data[theApp.m_learn_count].GetAt(i)!=theApp.m_learn_data[theApp.m_learn_count-1].GetAt(i))
					{
						b=false;		//不等校验失败
						break;
					}
			}
			else
				b=false;
		}
		if (b) theApp.m_learn_count++;
		else theApp.m_learn_count=0;	*/
		((CNetSDKDemoDlg*)theApp.m_pMainWnd)->m_dlgIr.PostMessage(WM_IR_RECIEVE,1,0);		//theApp.m_learn_count
	}
	else
	{//非学习状况,既控制状态
		int i,j;
		b=false;		//没有找到匹配按键,sel
		for (i=0;i<COUNT_BUTTON;i++)
		{//循环按键数组
			if ((DWORD)theApp.m_ir_data[i].GetSize()==InBufferCount)
			{
				for (j=0;j<theApp.m_ir_data[i].GetSize();j++)		//循环判断按键码
					if (theApp.m_ir_data[i].GetAt(j)!=p[j]) break;
				if (j==theApp.m_ir_data[i].GetSize()) break;
			}
		}
		if (i<COUNT_BUTTON)
		{
			//theApp.RemoteControl(i);		//找到了匹配按键,按键序号为i
			b=false;
			if (i==17)
			{			//查找是否有提示框,有则去掉
				HWND hDlg=::FindWindow(NULL,theApp.m_pszAppName);
				if (hDlg!=NULL && hDlg!=theApp.m_pMainWnd->m_hWnd)
				{
					::PostMessage(hDlg,WM_CLOSE,0,0);
					b=true;
				}
				hDlg=::FindWindow(NULL,"Hikhcplugin");
				if (hDlg!=NULL)
				{
					::PostMessage(hDlg,WM_CLOSE,0,0);
					b=true;
				}
				hDlg=::FindWindow(NULL,"hikmp4net");
				if (hDlg!=NULL)
				{
					::PostMessage(hDlg,WM_CLOSE,0,0);
					b=true;
				}
				hDlg=::FindWindow(NULL,"DvrClientDemo");
				if (hDlg!=NULL)
				{
					::PostMessage(hDlg,WM_CLOSE,0,0);		//SendMessage(WndHwnd,   WM_SYSCOMMAND,   SC_CLOSE,   0);   
					b=true;
				}
				hDlg=::FindWindow(NULL,"hikmeplugin");
				if (hDlg!=NULL)
				{
					::PostMessage(hDlg,WM_CLOSE,0,0);
					b=true;
				}
			}
			if (b) return;
			theApp.m_pMainWnd->PostMessage(WM_IR_RECIEVE,0,i);		//给窗口发消息避免堵塞线程
			/*//new
			if (i==9 && ::FindWindow(NULL,"VOD")==NULL)
			{
				HWND	hVod;
				int img,sel_img,channel;
				HTREEITEM hDvr;
				HTREEITEM hItem = ((CNetSDKDemoDlg*)theApp.m_pMainWnd)->m_treeDevice.GetSelectedItem();
				if (hItem!=NULL)
				{
					channel=-1;
					((CNetSDKDemoDlg*)theApp.m_pMainWnd)->m_dlgDvr.m_treeDevice.GetItemImage(hItem,img,sel_img);
					if (img==3)
					{	//当前选择的是通道节点
						hDvr=((CDvrClientDemoDlg*)theApp.m_pMainWnd)->m_dlgDvr.m_treeDevice.GetParentItem(hItem);
						channel = (int)((CDvrClientDemoDlg*)theApp.m_pMainWnd)->m_dlgDvr.m_treeDevice.GetItemData(hItem);
					}
					else
					if (img==1)
					{
						hDvr=hItem;
						channel=0;
					}
					if (channel>=0)
						//需要初始化vod窗口
						for (i=0;i<15;i++)		//等待15秒
						{
							Sleep(1000);
							hVod=::FindWindow(NULL,"VOD");
							if (hVod!=NULL)
							{
								HWND hControl=::GetDlgItem(hVod,1005);		//通道组合框
								::SendMessage(hControl,CB_SETCURSEL,channel,0);		//设置选择的通道
								::SendMessage(::GetDlgItem(hVod,1120),LVM_SETCOLUMNWIDTH,0,MAKELPARAM(5,0));
								DWORD dwStyle = ListView_GetExtendedListViewStyle(::GetDlgItem(hVod,1120));
								dwStyle |=  LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES  | LVS_EX_HEADERDRAGDROP ;
								ListView_SetExtendedListViewStyle(::GetDlgItem(hVod,1120), dwStyle);

								SYSTEMTIME dt;
								GetLocalTime(&dt);
								dt.wHour=0;
								dt.wMinute=0;
								dt.wSecond=0;
								dt.wMilliseconds=0;
								CTime cdt=CTime(dt);
								hControl=::GetDlgItem(hVod,1074);		//开始日期
								DateTime_SetSystemtime(hControl,GDT_VALID,&dt);
								hControl=::GetDlgItem(hVod,1075);		//开始时间
								DateTime_SetSystemtime(hControl,GDT_VALID,&dt);
								cdt+=CTimeSpan(1,0,0,0);
								cdt.GetAsSystemTime(dt);
								hControl=::GetDlgItem(hVod,1077);		//结束日期
								DateTime_SetSystemtime(hControl,GDT_VALID,&dt);
								hControl=::GetDlgItem(hVod,1078);		//结束日期
								DateTime_SetSystemtime(hControl,GDT_VALID,&dt);

//								开始日期(SysDateTimePick32)	432
//								开始时间(SysDateTimePick32)	433
//								结束日期(SysDateTimePick32)	435
//								结束时间(SysDateTimePick32)	436(1078d)
								hControl=::GetDlgItem(hVod,1091);		//单窗口按钮
								::SendMessage(hControl,BM_CLICK,0,0);	//点击搜索按钮
								hControl=::GetDlgItem(hVod,1065);		//搜索按钮
								::SendMessage(hControl,BM_CLICK,0,0);	//点击搜索按钮
								//初始化vod窗口
								break;
							}		//end of if (hVod!=NULL)
						}		//end of for (i=0;i<7;i++)
				}
			}//new		//end of if (i==9 && ::FindWindow(NULL,"VOD")==NULL)
			*/
		}
	}		//end of if (theApp.m_learn)
}

⌨️ 快捷键说明

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