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

📄 dlg_ch.cpp

📁 一个在Linux下开发的IP摄像头的驱动程序及控制软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
					pButton=(CButton *)GetDlgItem(IDC_RADIO1);
					pButton->SetCheck(BST_CHECKED);

					for ( i=0 ; i < 3 ; i ++)
					{
						pButton=(CButton *)GetDlgItem(IDC_RADIO_VO + i);
						pButton->EnableWindow(TRUE);
					}

					pButton=(CButton *)GetDlgItem(IDC_RADIO_AV);
					pButton->SetCheck(BST_CHECKED);
				}
			}
		}
		else
		{
			pButton=(CButton *)GetDlgItem(IDC_RADIO1);
			pButton->EnableWindow(TRUE);
			pButton=(CButton *)GetDlgItem(IDC_RADIO2);
			pButton->EnableWindow(TRUE);
			pButton=(CButton *)GetDlgItem(IDC_RADIO3);
			pButton->EnableWindow(TRUE);
			pButton=(CButton *)GetDlgItem(IDC_RADIO4);
			pButton->EnableWindow(TRUE);
			pButton=(CButton *)GetDlgItem(IDC_RADIO5);
			pButton->EnableWindow(TRUE);
			pButton=(CButton *)GetDlgItem(IDC_RADIO6);
			pButton->EnableWindow(TRUE);
			pButton=(CButton *)GetDlgItem(IDC_RADIO7);
			pButton->EnableWindow(TRUE);
			pButton=(CButton *)GetDlgItem(IDC_RADIO_VO);
			pButton->EnableWindow(TRUE);
			pButton=(CButton *)GetDlgItem(IDC_RADIO_AO);
			pButton->EnableWindow(TRUE);
			pButton=(CButton *)GetDlgItem(IDC_RADIO_AV);
			pButton->EnableWindow(TRUE);
		}		
	}
	else
	{
		pButton=(CButton *)GetDlgItem(IDC_RADIO_VO);
		pButton->SetCheck(BST_CHECKED);
	}
}

//#define	_SERVERUTL_NON_BLOCKING

#ifndef _SERVERUTL_NON_BLOCKING
void DLG_CH::OnBnClickedButton1()
{
	// TODO: Add your control notification handler code here
	HANDLE hObject,hDevice;
	TSERVERUTL_DEV_PROPERTY tDevProperty;
	char lpszModelName[64]; 

	CWaitCursor wc;
	char chHost[64];
	char chPassword[64];
	char chUserName[64];
	ZeroMemory(&tDevProperty, sizeof(tDevProperty));
	m_HOSTIP.GetWindowText(chHost,sizeof(chHost));
	tDevProperty.lpszHost=chHost;
	m_Password.GetWindowText(chPassword,sizeof(chPassword));
	tDevProperty.lpszPassword=chPassword;
	m_UserName.GetWindowText(chUserName,sizeof(chUserName));
	tDevProperty.lpszUserName=chUserName;
	tDevProperty.dwTimeout = 10000;
	char szBuf[MAX_PATH];
	m_Port.GetWindowText(szBuf, MAX_PATH);
	tDevProperty.dwHttpPort = atoi(szBuf);

	if ( NULL == *m_phSrvUtl )
	{
		ServerUtl_Initial(m_phSrvUtl,SERVERUTL_VERSION);
	}

	hObject = *m_phSrvUtl;

	ServerUtl_CreateDevice(hObject,&hDevice);
	SCODE sRet = ServerUtl_SetDeviceProperty(hDevice,tDevProperty, FALSE);
	if (sRet != S_OK)
	{
		if (sRet == SERVUTL_E_AUTH)
			MessageBox("User name or password incorrect");
		else
			MessageBox("Can't connect to server");
		return;
	}

	lpszModelName[0] = 0;
	ServerUtl_GetDeviceModel(hDevice,lpszModelName);

#if 0
	DIDOSTATUS aDiStatus[4];
	ServerUtl_GetDIStatus(hDevice, &aDiStatus[0], &aDiStatus[1], &aDiStatus[2], 
		&aDiStatus[3], FALSE);
#endif // 0

	ServerUtl_OpenDevice(hDevice, lpszModelName);

#if 0
	sRet = ServerUtl_SendPTZCommand(hDevice, 1, SERVERUTL_PTZ_FOCUS_AUTO, "", FALSE);
	if (sRet != S_OK)
		MessageBox("Error");
	else
		MessageBox("Send PTZ OK");
#endif // 0

	ServerUtl_DeleteDevice(hDevice);
	if (lpszModelName[0] == 0)
	{
		MessageBox("Get Model name failed");
		return;
	}
	//ServerUtl_Release(&hObject);
	
	char FriendlyName[64];
	FriendlyName[0] = 0;

	SrvDepResource_GetMappingFriendlyName(lpszModelName,FriendlyName);

	CString s2;
	for ( int i=0 ; i < m_ServerModel.GetCount() ; i++ )
	{
		m_ServerModel.GetLBText(i,s2);
		if ( s2.Find(FriendlyName,0) > -1 )
		{
			//MessageBox(FriendlyName,"Server Model",MB_OK);
			m_ServerModel.SetCurSel(i);
			CheckServerModel();
			break;
		}
	}

	if ( i == m_ServerModel.GetCount() )
	{
		if (strlen(FriendlyName) > 6)
		{
			char szTemp[256];

			strcpy(szTemp, FriendlyName);
			szTemp[6] = 0;

			for ( i=0 ; i < m_ServerModel.GetCount() ; i++ )
			{
				m_ServerModel.GetLBText(i,s2);
				if ( s2.Find(szTemp, 0) > -1 )
				{
					//MessageBox(FriendlyName,"Server Model",MB_OK);
					m_ServerModel.SetCurSel(i);
					CheckServerModel();
					break;
				}
			}
		}
	}

	if ( i == m_ServerModel.GetCount() )
	{
		char s3[128];
		sprintf(s3,"Don't support this Server Model: %s",FriendlyName);
		MessageBox(s3,NULL,MB_ICONWARNING);
		m_HOSTIP.SetWindowText("");
		m_Password.SetWindowText("");
		m_UserName.SetWindowText("");
		m_ServerModel.SetWindowText("");
	}
}
#else
void StatusCallback(HANDLE	hDevice, DWORD	dwContext, DWORD	dwStatus,
                    DWORD	dwParam1, DWORD	dwParam2)
{
	DLG_CH *pDlg = (DLG_CH *) dwContext;

	if (dwStatus == SERVERUTL_STATUS_SET_PROPERTY)
	{
		if (dwParam1 != 0)
		{
			if (dwParam1 == SERVERUTL_ERR_AUTH_FAILED)
				pDlg->MessageBox("User name or password incorrect!");
			else
				pDlg->MessageBox("Can't connect to server");
			ServerUtl_DeleteDevice(hDevice);
			pDlg->EnableWindow(TRUE);
			SetCursor(LoadCursor(NULL, IDC_ARROW));
			return;
		}

		char lpszModelName[64]; 
		lpszModelName[0] = 0;
		ServerUtl_GetDeviceModel(hDevice,lpszModelName);
		ServerUtl_DeleteDevice(hDevice);
		if (lpszModelName[0] == 0)
		{
			pDlg->MessageBox("Get Model name failed");
			pDlg->EnableWindow(TRUE);
			SetCursor(LoadCursor(NULL, IDC_ARROW));
			return;
		}
		//ServerUtl_Release(&hObject);
		
		char FriendlyName[64];
		FriendlyName[0] = 0;
		SrvDepResource_GetMappingFriendlyName(lpszModelName,FriendlyName);

		CString s2;
		for ( int i=0 ; i < pDlg->m_ServerModel.GetCount() ; i++ )
		{
			pDlg->m_ServerModel.GetLBText(i,s2);
			if ( s2.Find(FriendlyName,0) > -1 )
			{
				//MessageBox(FriendlyName,"Server Model",MB_OK);
				pDlg->m_ServerModel.SetCurSel(i);
				pDlg->CheckServerModel();
				break;
			}
		}

		if ( i == m_ServerModel.GetCount() )
		{
			if (strlen(FriendlyName) > 6)
			{
				char szTemp[256];

				strcpy(szTemp, FriendlyName);
				szTemp[6] = 0;

				for ( i=0 ; i < m_ServerModel.GetCount() ; i++ )
				{
					m_ServerModel.GetLBText(i,s2);
					if ( s2.Find(szTemp, 0) > -1 )
					{
						//MessageBox(FriendlyName,"Server Model",MB_OK);
						m_ServerModel.SetCurSel(i);
						CheckServerModel();
						break;
					}
				}
			}
		}

		if ( i == pDlg->m_ServerModel.GetCount() )
		{
			char s3[128];
			sprintf(s3,"Don't support this Server Model: %s",FriendlyName);
			pDlg->MessageBox(s3,NULL,MB_ICONWARNING);
			pDlg->m_HOSTIP.SetWindowText("");
			pDlg->m_Password.SetWindowText("");
			pDlg->m_UserName.SetWindowText("");
			pDlg->m_ServerModel.SetWindowText("");
		}
		pDlg->EnableWindow(TRUE);
		SetCursor(LoadCursor(NULL, IDC_ARROW));
	}
}

void DLG_CH::OnBnClickedButton1()
{
	EnableWindow(FALSE);
	// TODO: Add your control notification handler code here
	HANDLE hObject,hDevice;
	TSERVERUTL_DEV_PROPERTY tDevProperty;
	char lpszModelName[64]; 

	SetCursor(LoadCursor(NULL, IDC_WAIT));
	char chHost[64];
	char chPassword[64];
	char chUserName[64];
	ZeroMemory(&tDevProperty, sizeof(tDevProperty));
	m_HOSTIP.GetWindowText(chHost,sizeof(chHost));
	tDevProperty.lpszHost=chHost;
	m_Password.GetWindowText(chPassword,sizeof(chPassword));
	tDevProperty.lpszPassword=chPassword;
	m_UserName.GetWindowText(chUserName,sizeof(chUserName));
	tDevProperty.lpszUserName=chUserName;
	tDevProperty.dwTimeout = 30000;
	tDevProperty.pfStatusCallback = StatusCallback;
	tDevProperty.dwContext = (DWORD) this;
	char szBuf[MAX_PATH];
	m_Port.GetWindowText(szBuf, MAX_PATH);
	tDevProperty.dwHttpPort = atoi(szBuf);

	if ( NULL == *m_phSrvUtl )
	{
		ServerUtl_Initial(m_phSrvUtl,SERVERUTL_VERSION);
	}

	hObject = *m_phSrvUtl;

	ServerUtl_CreateDevice(hObject,&hDevice);
	SCODE sRet = ServerUtl_SetDeviceProperty(hDevice,tDevProperty, TRUE);
	if (sRet != S_OK)
	{
		EnableWindow(TRUE);
		if (sRet == SERVUTL_E_AUTH)
			MessageBox("User name or password incorrect");
		else
			MessageBox("Can't connect to server");
		return;
	}

	return;
}
#endif // _SERVERUTL_NON_BLOCKING

void DLG_CH::DoWhenProtocolChanged()
{
	UpdateData();
	CButton *pButton;

	if (m_Ch_Info.chServer_Type[2] == '3')
	{
		// move the media type according to protocol
		if (m_Protocol <= 1)
		{
			pButton=(CButton *)GetDlgItem(IDC_RADIO_AV);
		}
		else
		{
			pButton=(CButton *)GetDlgItem(IDC_RADIO_VO);
		}
		pButton->SetCheck(BST_CHECKED);
	}
}

void DLG_CH::OnBnClickedRadio1()
{
}

void DLG_CH::OnBnClickedRadio2()
{
	// TODO: Add your control notification handler code here
}

void DLG_CH::OnBnClickedRadio3()
{
}

⌨️ 快捷键说明

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