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

📄 dlgconfigset.cpp

📁 电子监控的网络编程实例
💻 CPP
字号:
// DlgConfigSet.cpp : implementation file
//

#include "stdafx.h"
#include "VideoCapture.h"
#include "DlgConfigSet.h"
#include "VideoCaptureView.h"

//#include "DlgLicense.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgConfigSet dialog


CDlgConfigSet::CDlgConfigSet(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgConfigSet::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgConfigSet)
	//}}AFX_DATA_INIT
}


void CDlgConfigSet::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgConfigSet)
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgConfigSet, CDialog)
	//{{AFX_MSG_MAP(CDlgConfigSet)
	ON_BN_CLICKED(IDC_RADIO_MANUAL, OnRadioManual)
	ON_BN_CLICKED(IDC_RADIO_AUTO, OnRadioAuto)
	ON_WM_CTLCOLOR()
	ON_BN_CLICKED(IDC_CHECK_AUTO_TRANS, OnCheckAutoTrans)
	ON_BN_CLICKED(IDC_CAP_SMALL_CAR, OnCapSmallcar)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()



BOOL CDlgConfigSet::OnInitDialog() 
{
	CDialog::OnInitDialog();


//自动抓拍,初始化界面元素	
	((CButton*)GetDlgItem(IDC_RADIO_AUTO))->SetCheck(TRUE);


	CVideoCaptureView * pView=CVideoCaptureView::GetView();
	if(pView)
	{
		CString strstr;

		if(pView->TransMode==0){
			GetDlgItem(IDC_CHECK_AUTO_TRANS)->EnableWindow(FALSE);
		}
		else{
			((CButton *)GetDlgItem(IDC_CHECK_AUTO_TRANS))->SetCheck(TRUE);
		}
		
		strstr.Format("%d",pView->m_iSpeed);
		GetDlgItem(IDC_LIMITED_SPEED)->SetWindowText(strstr);
		
		if (pView->m_bCapMinSpeed)
		{
			GetDlgItem(IDC_DOWN_SPEED)->EnableWindow();
			strstr.Format("%d",pView->m_iSpeedDown);
			GetDlgItem(IDC_DOWN_SPEED)->SetWindowText(strstr);
		}
		if (pView->m_bCapSmallCarSpeed)
		{
			GetDlgItem(IDC_UP_SPEED)->EnableWindow();
			strstr.Format("%d",pView->m_iSpeedUp);
			GetDlgItem(IDC_UP_SPEED)->SetWindowText(strstr);
			
		}
	}	
	return TRUE;  
}

/***-------------------------------------------------------------------------------
选择手动抓拍//
设置相关  功能 (允许在主界面上修改数据)
-------------------------------------------------------------------------------***/
void CDlgConfigSet::OnRadioManual() 
{
	
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	if(!pView)
		return;
	pView->m_bAutoCap=FALSE;
// 	pView->m_SnapAutoMode=FALSE;
	pView->GetDlgItem(IDC_BTNIMAGECAP)->EnableWindow(TRUE);
	pView->GetDlgItem(IDC_BTNVIDEOCAP)->EnableWindow(TRUE);

//	CString str;
//	GetDlgItem(IDC_IMAGE_NUM)->GetWindowText(str);
//	m_num=atoi(str);

}

/***-------------------------------------------------------------------------------
选择自动抓拍//
设置相关  功能 (禁止在主界面上修改数据)
-------------------------------------------------------------------------------***/
void CDlgConfigSet::OnRadioAuto() 
{
	
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	if(!pView)
		return;
	pView->m_bAutoCap=TRUE;
	pView->GetDlgItem(IDC_BTNVIDEOCAP)->EnableWindow(FALSE);
}

//使回车键  失去作用(对话框不会隐藏)
void CDlgConfigSet::OnOK() 
{

//	CDialog::OnOK();
}
void CDlgConfigSet::OnCancel() 
{
	//CDialog::OnCancel();
}


//消息处理 WM_LICENSE_CHANGE  修改号牌文本
//void CDlgConfigSet::LicenseHaveChange(WPARAM wParam, LPARAM lParam)
//{
	//GetDlgItem(IDC_LICENSE)->SetWindowText(m_licenseText);	
//}

BOOL CDlgConfigSet::PreTranslateMessage(MSG* pMsg) 
{
	
	if(pMsg->message==WM_KEYDOWN)
	{
		switch(pMsg->wParam) {
		case 74://J
			CaptureImage();
			break;
		case 75://K
			CaptureVideo();
			break;
		case 76://L
			ShellExecute(NULL,"Open",".\\QueryDeal.exe","","",SW_MAXIMIZE);
			::Sleep(5000);
			break;
		case 'Q'://L
			exit(0);
			break;
		case 'V':
			ShellExecute(NULL,"Open",".\\log.txt","","",SW_NORMAL);
			break;
		case 'C':
			SetCapParam();
			break;
		case 'M':
			SetComm();
			break;
		case 'H':
			SetZDJC();
			break;
		case 'R':
			SetRadar();
			break;
		case VK_F9:
			SetAuto();
			break;
		case 119://VK_F8:
			if(((CButton*)GetDlgItem(IDC_CHECK_AUTO_TRANS))->GetCheck()){
				((CButton*)GetDlgItem(IDC_CHECK_AUTO_TRANS))->SetCheck(FALSE);
			}			
			else
			{
				((CButton*)GetDlgItem(IDC_CHECK_AUTO_TRANS))->SetCheck(TRUE);
				
			}
			OnCheckAutoTrans();
			break;
		case 190://"."
			OnCapSmallcar();
			break;
		}
				
	}	
	
	return CDialog::PreTranslateMessage(pMsg);
}


void CDlgConfigSet::SetAuto()
{
	if ( ((CButton*)GetDlgItem(IDC_RADIO_AUTO))->GetCheck()==BST_CHECKED )
		//	if (GetDlgItem(IDC_RADIO_AUTO)->IsWindowEnabled())
	{
		((CButton*)GetDlgItem(IDC_RADIO_MANUAL))->SetCheck(BST_CHECKED);
		((CButton*)GetDlgItem(IDC_RADIO_AUTO))->SetCheck(BST_UNCHECKED);
		OnRadioManual();//手动抓拍	
	}
	else
	{
		((CButton*)GetDlgItem(IDC_RADIO_AUTO))->SetCheck(BST_CHECKED);
		((CButton*)GetDlgItem(IDC_RADIO_MANUAL))->SetCheck(BST_UNCHECKED);
		OnRadioAuto();//自动抓拍
	}
}

//手动抓拍图像
void CDlgConfigSet::CaptureImage()
{
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	if(pView)
	{
		pView->OnBtnimagecap();
	}
}

//手动抓拍视频
void CDlgConfigSet::CaptureVideo()
{
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	if(pView)
	{
		pView->OnBtnvideocap();
	}
}

//设置抓拍参数
void CDlgConfigSet::SetCapParam()
{
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	if(pView)
	{
		pView->GetDlgItem(IDC_BTNAUTOSET)->SetFocus();
		pView->OnBtnautoset();
	}
}

//设置图像参数

void CDlgConfigSet::SetImage()
{
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	if(pView)
	{
		pView->GetDlgItem(IDC_BTNSETIMAGE)->SetFocus();
	}
}

//设置串口
void CDlgConfigSet::SetComm()
{
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	if(pView)
	{
		pView->GetDlgItem(IDC_BTNSETCOM)->SetFocus();
		pView->OnBtnsetcom();
	}
}
//设置雷达
void CDlgConfigSet::SetRadar()
{
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	if(pView)
	{
		pView->GetDlgItem(IDC_BTNSETRADAR)->SetFocus();
		pView->OnBtnsetradar();
	}
}

HBRUSH CDlgConfigSet::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	if (nCtlColor== CTLCOLOR_EDIT )
	{
		
		LOGFONT lf;
		::ZeroMemory(&lf,sizeof(lf));
		lf.lfHeight=90;
		lf.lfWeight=FW_BOLD;
		::lstrcpy(lf.lfFaceName,_T("黑体"));
		CFont font;
		font.CreatePointFontIndirect(&lf);
		
		CFont* pOldFont=pDC->SelectObject(&font);

		pDC->SetTextColor (RGB (255 , 0 , 0 ) ) ;

	}
	return hbr ; 
}

void CDlgConfigSet::OnCheckAutoTrans() 
{
	
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	while(!pView)
	{
		Sleep(0);
		pView=(CVideoCaptureView*)GetParent();
	}
	pView->m_bAutoTrans=((CButton*)GetDlgItem(IDC_CHECK_AUTO_TRANS))->GetCheck();
}


void CDlgConfigSet::OnCapSmallcar() 
{
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	while(!pView)
	{
	//	Sleep(100);
		pView=(CVideoCaptureView*)GetParent();
	}
	pView->m_bSmallCar=!pView->m_bSmallCar;
		if (pView->m_bSmallCar)
	{
		pView->m_iSpeedTemp=pView->m_iSpeed;
		pView->m_iSpeed=pView->m_iSpeedUp;
	//	m_iSpeedTemp=m_iSpeed;
	}
	else
	{
		pView->m_iSpeed=pView->m_iSpeedTemp;
	//	m_iSpeed=m_iSpeedUp;
	}
	((CButton*)GetDlgItem(IDC_CAP_SMALL_CAR))->SetCheck(pView->m_bSmallCar);		
}

//切换流动稽查和超速抓拍
void CDlgConfigSet::SetZDJC()
{	
	CVideoCaptureView* pView=(CVideoCaptureView*)GetParent();
	while(!pView)
	{		
		pView=(CVideoCaptureView*)GetParent();
	}

	pView->GetDlgItem(IDC_BTNLDJC)->SetFocus();
	pView->SetZDJC();

}

⌨️ 快捷键说明

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