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

📄 camconfigdlg.cpp

📁 用Embedded Visual C++ Win32 API开发的运行于Windows CE Pocket PC的多点移动视频监控软件
💻 CPP
字号:
// CamConfigDlg.cpp: implementation of the CCamConfigDlg class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CamConfigDlg.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCamConfigDlg::CCamConfigDlg()
{

}

CCamConfigDlg::CCamConfigDlg(HWND theDlg, CAllCam *p)
{
	this->hDlg =theDlg;
	this->pAllCam = p;
}

void CCamConfigDlg::Set(HWND theDlg, CAllCam *p)
{
	this->hDlg =theDlg;
	this->pAllCam = p;
}


CCamConfigDlg::~CCamConfigDlg()
{

}

void CCamConfigDlg::InitListbox(int resource)
{
	HWND hItem;
	hItem = ::GetDlgItem (this->hDlg , resource);

	if(hItem == NULL)	return;

	CCamDesc *p;

	p = pAllCam->pCam ;

	for (int i=0; i<pAllCam->num ; i++)
	{
		p = pAllCam->pCam ;
		p += i;
		::SendMessage (hItem, LB_ADDSTRING, (WPARAM)0, (LPARAM)p->Name );
	}
}

void CCamConfigDlg::ClearListbox(int resource)
{
	HWND hItem;
	hItem = ::GetDlgItem (this->hDlg , resource);

	if(hItem == NULL)	return;

	for(;;)
	{
		if(::SendMessage (hItem, LB_GETCOUNT, 0, 0 ) ==0)	break;
		::SendMessage (hItem, LB_DELETESTRING, (WPARAM) 0, 0);
	}
}

void CCamConfigDlg::DisposeListboxMsg(int resource)
{
	HWND hItem;
	hItem = ::GetDlgItem (this->hDlg , resource);

	if(hItem == NULL)	return;

	int idx = ::SendMessage (hItem, LB_GETCURSEL, (WPARAM)0, (LPARAM)0 );

	TCHAR theName[255];

	::SendMessage (hItem, LB_GETTEXT,  (WPARAM)idx, (LPARAM)theName );

	////////////////////////
	CCamDesc *p;

	for (int i=0; i<pAllCam->num ; i++)
	{
		p = pAllCam->pCam ;
		p += i;
		if(wcscmp(theName, p->Name ) ==0 )	break;
	}

	this->FromCCamDescToMe (p);
}

void CCamConfigDlg::FromCCamDescToMe(CCamDesc *pCam)
{
	wcscpy(this->Name , pCam->Name );
	wcscpy(this->Path , pCam->Path );
	wcscpy(this->Type , pCam->Type );
	this->IO = pCam->IO ;
	this->ptz = pCam->PTZ ;
}

void CCamConfigDlg::FromMeToCCamDesc(CCamDesc *pCam)
{

}

BOOL CCamConfigDlg::IsCameraNameDuplicate()
{
	CCamDesc *p;

	for (int i=0; i<pAllCam->num ; i++)
	{
		p = pAllCam->pCam ;
		p += i;
		if(wcscmp(this->Name , p->Name ) ==0 )	return TRUE;
	}
	return FALSE;
}

void CCamConfigDlg::SaveMe()
{
	CCamDesc theCam;

	_tcscpy(theCam.Name , this->Name );
	_tcscpy(theCam.Path , this->Path );
	_tcscpy(theCam.Username , this->Username );
	_tcscpy(theCam.Password , this->Password );

	_tcscpy(theCam.Type , this->Type );
	theCam.IO = this->IO ;
	theCam.Status = 1;
	theCam.PTZ = this->ptz  ;

	theCam.SaveMe ();
}





BOOL CCamConfigDlg::DeleteMeFromRegestry()
{
	CCamDesc theCam;
	_tcscpy(theCam.Name , this->Name );
	return theCam.DeleteMeFromRegestry ();
}

void CCamConfigDlg::BackupMe()
{
	HANDLE handle = INVALID_HANDLE_VALUE;
	while(handle == INVALID_HANDLE_VALUE)
		handle= ::CreateFile (CAMCFGFILE, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

	CCamDesc *p;
	DWORD dwBytes;

	dwBytes = sizeof(DWORD);
	::WriteFile (handle, &(pAllCam->num)  , dwBytes, &dwBytes, NULL);

	for(int i=0; i<pAllCam->num ; i++)
	{
		p = pAllCam->pCam ;
		p+=i;
		dwBytes = 255 *sizeof(TCHAR);
		::WriteFile (handle, p->Name , dwBytes, &dwBytes, NULL);
		dwBytes = 255 *sizeof(TCHAR);
		::WriteFile (handle, p->Path , dwBytes, &dwBytes, NULL);
		dwBytes = 255 *sizeof(TCHAR);
		::WriteFile (handle, p->Type , dwBytes, &dwBytes, NULL);

		dwBytes = sizeof(DWORD);
		::WriteFile (handle, &(p->Status)  , dwBytes, &dwBytes, NULL);
		dwBytes = sizeof(DWORD);
		::WriteFile (handle, &(p->IO) , dwBytes, &dwBytes, NULL);
		dwBytes = sizeof(DWORD);
		::WriteFile (handle, &(p->PTZ) , dwBytes, &dwBytes, NULL);
	}
	
	while(::CloseHandle (handle)==0)	;
}

void CCamConfigDlg::RestoreMe()
{
	CCamDesc *p;
	DWORD dwBytes;

	int i;
	for (i=0; i<this->pAllCam ->num ; i++)
	{
		p = this->pAllCam ->pCam ;
		p+=i;
		p->DeleteMeFromRegestry ();
	}

	HANDLE handle = INVALID_HANDLE_VALUE;
	handle= ::CreateFile (CAMCFGFILE, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
	if (handle == INVALID_HANDLE_VALUE)		return;

	dwBytes = sizeof(DWORD);
	::ReadFile (handle, &(pAllCam->num)  , dwBytes, &dwBytes, NULL);

	if(pAllCam->pCam !=NULL)	{	free(pAllCam->pCam) ;	pAllCam->pCam=NULL;		}
	do {	pAllCam->pCam = (CCamDesc *)malloc(pAllCam->num * sizeof(CCamDesc) );	}	while ( pAllCam->pCam==NULL)	;

	if(pAllCam->pCam ==NULL )	
	{
		while(::CloseHandle (handle)==0)	;
		return;
	}

	for(i=0; i<pAllCam->num ; i++)
	{
		p = pAllCam->pCam ;
		p+=i;
		dwBytes = 255 *sizeof(TCHAR);
		::ReadFile (handle, p->Name , dwBytes, &dwBytes, NULL);
		dwBytes = 255 *sizeof(TCHAR);
		::ReadFile (handle, p->Path , dwBytes, &dwBytes, NULL);
		dwBytes = 255 *sizeof(TCHAR);
		::ReadFile (handle, p->Type , dwBytes, &dwBytes, NULL);

		dwBytes = sizeof(DWORD);
		::ReadFile (handle, &(p->Status)  , dwBytes, &dwBytes, NULL);
		dwBytes = sizeof(DWORD);
		::ReadFile (handle, &(p->IO) , dwBytes, &dwBytes, NULL);
		dwBytes = sizeof(DWORD);
		::ReadFile (handle, &(p->PTZ) , dwBytes, &dwBytes, NULL);
	}
	
	while(::CloseHandle (handle)==0)	;

	//////////////////////
	this->pAllCam ->InitializeRegistry ();
}

⌨️ 快捷键说明

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