📄 remotedetectconfig.cpp
字号:
// RemoteDetectConfig.cpp : implementation file
//
#include "stdafx.h"
#include "newclient.h"
#include "RemoteDetectConfig.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern LPNET_DVR_MOTION lpMotionDetect;
int m_idetectnum;
RECT g_ShowRect[2];
RECT g_MouseRect[2];
/////////////////////////////////////////////////////////////////////////////
// CRemoteDetectConfig dialog
void CALLBACK DrawFunShow(long nPort,HDC hDc,DWORD nUser)
{
TRACE("show motion detect area.");
CRect rect;
int i = 0,j = 0;
CPoint point;
for(i = 0;i<18;i++)
{
for(j = 0;j<22;j++)
{
if(lpMotionDetect->byMotionScope[i][j] == 1)
{
point.x = j*16;
point.y = i*16;
rect.left = point.x;
rect.top = point.y;
rect.right = point.x + 16;
rect.bottom = point.y + 16;
::DrawEdge(hDc,&rect,BDR_SUNKENOUTER,BF_RECT);
}
}
}
SetBkMode(hDc,TRANSPARENT);
}
void CALLBACK DrawFun(long nPort,HDC hDc,DWORD nUser)
{
for(int i=0;i<m_idetectnum;i++)
::DrawEdge(hDc,&g_ShowRect[i],BDR_SUNKENOUTER,BF_RECT);
SetBkMode(hDc,TRANSPARENT);
}
CRemoteDetectConfig::CRemoteDetectConfig(CWnd* pParent /*=NULL*/)
: CDialog(CRemoteDetectConfig::IDD, pParent)
{
//{{AFX_DATA_INIT(CRemoteDetectConfig)
m_bShowdetect = FALSE;
m_bSetdetect = FALSE;
m_bHandleType1 = FALSE;
m_bHandleType2 = FALSE;
m_bHandleType3 = FALSE;
m_bHandleType4 = FALSE;
m_bAlarmOut1 = FALSE;
m_bAlarmOut2 = FALSE;
m_bAlarmOut3 = FALSE;
m_bAlarmOut4 = FALSE;
m_bRecordChan1 = FALSE;
m_bRecordChan10 = FALSE;
m_bRecordChan11 = FALSE;
m_bRecordChan12 = FALSE;
m_bRecordChan13 = FALSE;
m_bRecordChan14 = FALSE;
m_bRecordChan15 = FALSE;
m_bRecordChan16 = FALSE;
m_bRecordChan2 = FALSE;
m_bRecordChan3 = FALSE;
m_bRecordChan4 = FALSE;
m_bRecordChan5 = FALSE;
m_bRecordChan6 = FALSE;
m_bRecordChan7 = FALSE;
m_bRecordChan8 = FALSE;
m_bRecordChan9 = FALSE;
m_iHour11 = 0;
m_iHour12 = 0;
m_iHour21 = 0;
m_iHour22 = 0;
m_iHour32 = 0;
m_iHour31 = 0;
m_iHour41 = 0;
m_iHour42 = 0;
m_iMin11 = 0;
m_iMin12 = 0;
m_iMin21 = 0;
m_iMin31 = 0;
m_iMin22 = 0;
m_iMin32 = 0;
m_iMin41 = 0;
m_iMin42 = 0;
m_bHandleType5 = FALSE;
//}}AFX_DATA_INIT
}
void CRemoteDetectConfig::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRemoteDetectConfig)
DDX_Control(pDX, IDC_COMBOWEEKDAY, m_WeekDayCtrl);
DDX_Control(pDX, IDC_COMBOCOPYTIME, m_CopyTimeCtrl);
DDX_Control(pDX, IDC_DETECTPIC, m_DetectPic);
DDX_Control(pDX, IDC_COMBOSENSITIVE, m_SensitivityCtrl);
DDX_Check(pDX, IDC_CHECKGETRECT, m_bShowdetect);
DDX_Check(pDX, IDC_CHECKSETRECT, m_bSetdetect);
DDX_Check(pDX, IDC_CHECKHANDLETYPE1, m_bHandleType1);
DDX_Check(pDX, IDC_CHECKHANDLETYPE2, m_bHandleType2);
DDX_Check(pDX, IDC_CHECKHANDLETYPE3, m_bHandleType3);
DDX_Check(pDX, IDC_CHECKHANDLETYPE4, m_bHandleType4);
DDX_Check(pDX, IDC_CHKALARMOUT1, m_bAlarmOut1);
DDX_Check(pDX, IDC_CHKALARMOUT2, m_bAlarmOut2);
DDX_Check(pDX, IDC_CHKALARMOUT3, m_bAlarmOut3);
DDX_Check(pDX, IDC_CHKALARMOUT4, m_bAlarmOut4);
DDX_Check(pDX, IDC_RECORDCHAN1, m_bRecordChan1);
DDX_Check(pDX, IDC_RECORDCHAN10, m_bRecordChan10);
DDX_Check(pDX, IDC_RECORDCHAN11, m_bRecordChan11);
DDX_Check(pDX, IDC_RECORDCHAN12, m_bRecordChan12);
DDX_Check(pDX, IDC_RECORDCHAN13, m_bRecordChan13);
DDX_Check(pDX, IDC_RECORDCHAN14, m_bRecordChan14);
DDX_Check(pDX, IDC_RECORDCHAN15, m_bRecordChan15);
DDX_Check(pDX, IDC_RECORDCHAN16, m_bRecordChan16);
DDX_Check(pDX, IDC_RECORDCHAN2, m_bRecordChan2);
DDX_Check(pDX, IDC_RECORDCHAN3, m_bRecordChan3);
DDX_Check(pDX, IDC_RECORDCHAN4, m_bRecordChan4);
DDX_Check(pDX, IDC_RECORDCHAN5, m_bRecordChan5);
DDX_Check(pDX, IDC_RECORDCHAN6, m_bRecordChan6);
DDX_Check(pDX, IDC_RECORDCHAN7, m_bRecordChan7);
DDX_Check(pDX, IDC_RECORDCHAN8, m_bRecordChan8);
DDX_Check(pDX, IDC_RECORDCHAN9, m_bRecordChan9);
DDX_Text(pDX, IDC_EDITHOUR11, m_iHour11);
DDX_Text(pDX, IDC_EDITHOUR12, m_iHour12);
DDX_Text(pDX, IDC_EDITHOUR21, m_iHour21);
DDX_Text(pDX, IDC_EDITHOUR22, m_iHour22);
DDX_Text(pDX, IDC_EDITHOUR32, m_iHour32);
DDX_Text(pDX, IDC_EDITHOUR31, m_iHour31);
DDX_Text(pDX, IDC_EDITHOUR41, m_iHour41);
DDX_Text(pDX, IDC_EDITHOUR42, m_iHour42);
DDX_Text(pDX, IDC_EDITMIN11, m_iMin11);
DDX_Text(pDX, IDC_EDITMIN12, m_iMin12);
DDX_Text(pDX, IDC_EDITMIN21, m_iMin21);
DDX_Text(pDX, IDC_EDITMIN31, m_iMin31);
DDX_Text(pDX, IDC_EDITMIN22, m_iMin22);
DDX_Text(pDX, IDC_EDITMIN32, m_iMin32);
DDX_Text(pDX, IDC_EDITMIN41, m_iMin41);
DDX_Text(pDX, IDC_EDITMIN42, m_iMin42);
DDX_Check(pDX, IDC_CHECKHANDLETYPE5, m_bHandleType5);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRemoteDetectConfig, CDialog)
//{{AFX_MSG_MAP(CRemoteDetectConfig)
ON_BN_CLICKED(IDC_CHECKGETRECT, OnCheckgetrect)
ON_BN_CLICKED(IDC_CHECKSETRECT, OnChecksetrect)
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_TIMER()
ON_BN_CLICKED(IDMOTIONOK, OnMotionok)
ON_BN_CLICKED(IDEXIT, OnExit)
ON_BN_CLICKED(IDC_CHECKHANDLETYPE4, OnCheckhandletype4)
ON_BN_CLICKED(IDC_MOTIONTIMECOPY, OnMotiontimecopy)
ON_BN_CLICKED(IDC_MOTIONTIMEOK, OnMotiontimeok)
ON_CBN_SELCHANGE(IDC_COMBOWEEKDAY, OnSelchangeComboweekday)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRemoteDetectConfig message handlers
BOOL CRemoteDetectConfig::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
NET_DVR_CLIENTINFO playstru;
m_DetectPic.MoveWindow(DETECTPICTOP,DETECTPICTOP, 352, 288);
TRACE("Motion detect sensitivity: %d", lpMotionDetect->byMotionSensitive);
if(lpMotionDetect->byMotionSensitive == 0xFF)
{
m_SensitivityCtrl.SetCurSel(0);
}
else
{
m_SensitivityCtrl.SetCurSel(lpMotionDetect->byMotionSensitive+1);
}
F_ShowRecordChan(m_iChannelnumber);
playstru.hPlayWnd = m_DetectPic.GetSafeHwnd();
playstru.lChannel = m_iChannel;
playstru.lLinkMode = 0;
playstru.sMultiCastIP = "";
m_iPlayhandle = NET_DVR_RealPlay(m_lServerID, &playstru);
if(m_iPlayhandle == -1)
{
CString sTemp;
sTemp.Format("Network connect failed!");
AfxMessageBox(sTemp);
}
m_bDrawdetect = FALSE;
m_bSetMotion = FALSE;
m_bHandleType1 = lpMotionDetect->strMotionHandleType.dwHandleType &0x01;
m_bHandleType2 = (lpMotionDetect->strMotionHandleType.dwHandleType>>1)&0x01;
m_bHandleType3 = (lpMotionDetect->strMotionHandleType.dwHandleType>>2)&0x01;
m_bHandleType4 = (lpMotionDetect->strMotionHandleType.dwHandleType>>3)&0x01;
m_bHandleType5 = (lpMotionDetect->strMotionHandleType.dwHandleType>>4)&0x01;
EnableControl(m_bHandleType4);
GetDlgItem(IDC_CHECKGETRECT)->EnableWindow(TRUE);
GetDlgItem(IDC_CHECKSETRECT)->EnableWindow(TRUE);
GetDlgItem(IDMOTIONOK)->EnableWindow(TRUE);
m_WeekDayCtrl.SetCurSel(0);
m_CopyTimeCtrl.SetCurSel(0);
m_iHour11 = lpMotionDetect->struAlarmTime[0][0].byStartHour;
m_iMin11 = lpMotionDetect->struAlarmTime[0][0].byStartMin;
m_iHour12 = lpMotionDetect->struAlarmTime[0][0].byStopHour;
m_iMin12 = lpMotionDetect->struAlarmTime[0][0].byStopMin;
m_iHour21 = lpMotionDetect->struAlarmTime[0][1].byStartHour;
m_iMin21 = lpMotionDetect->struAlarmTime[0][1].byStartMin;
m_iHour22 = lpMotionDetect->struAlarmTime[0][1].byStopHour;
m_iMin22 = lpMotionDetect->struAlarmTime[0][1].byStopMin;
m_iHour31 = lpMotionDetect->struAlarmTime[0][2].byStartHour;
m_iMin31 = lpMotionDetect->struAlarmTime[0][2].byStartMin;
m_iHour32 = lpMotionDetect->struAlarmTime[0][2].byStopHour;
m_iMin32 = lpMotionDetect->struAlarmTime[0][2].byStopMin;
m_iHour41 = lpMotionDetect->struAlarmTime[0][3].byStartHour;
m_iMin41 = lpMotionDetect->struAlarmTime[0][3].byStartMin;
m_iHour42 = lpMotionDetect->struAlarmTime[0][3].byStopHour;
m_iMin42 = lpMotionDetect->struAlarmTime[0][3].byStopMin;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRemoteDetectConfig::OnCheckgetrect()
{
// TODO: Add your control notification handler code here
if(m_iPlayhandle < 0)
return;
UpdateData(TRUE);
if(m_bSetdetect)
{
m_bSetdetect = FALSE;
m_bDrawdetect = FALSE;
UpdateData(FALSE);
}
if(m_bShowdetect)
{
NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL, 0);
Sleep(200);
NET_DVR_RigisterDrawFun(m_iPlayhandle,DrawFunShow, 0);
}
else
{
NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL, 0);
}
}
void CRemoteDetectConfig::OnChecksetrect()
{
// TODO: Add your control notification handler code here
//Setup motion detect area
if(m_iPlayhandle < 0)
return;
UpdateData(TRUE);
if(m_bShowdetect)
{
m_bShowdetect = FALSE;
UpdateData(FALSE);
}
if(m_bSetdetect)
{
NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL,0);
m_idetectnum = 0;
m_bDrawdetect = TRUE;
m_bSetMotion = TRUE;
}
else
{
m_bDrawdetect = FALSE;
NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL,0);
}
}
void CRemoteDetectConfig::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_bDrawdetect)
{
if(MK_CONTROL&nFlags)
{
NET_DVR_RigisterDrawFun(m_iPlayhandle, DrawFun, 0);
if (m_idetectnum >=2)
m_idetectnum = 0;
point.x -= 5;
point.y -= 10;
g_MouseRect[m_idetectnum].left=point.x/16*16;
g_MouseRect[m_idetectnum].top=point.y/16*16;
g_MouseRect[m_idetectnum].right=g_MouseRect[m_idetectnum].left;
g_MouseRect[m_idetectnum].bottom=g_MouseRect[m_idetectnum].top;
POINT tPoint=point;
g_ShowRect[m_idetectnum].left=tPoint.x/16*16;
g_ShowRect[m_idetectnum].top=tPoint.y/16*16;
g_ShowRect[m_idetectnum].right=tPoint.x/16*16+1;
g_ShowRect[m_idetectnum].bottom=tPoint.y/16*16+1;
m_idetectnum ++;
}
}
CDialog::OnLButtonDown(nFlags, point);
}
void CRemoteDetectConfig::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_bDrawdetect)
{
if(MK_CONTROL&nFlags&&MK_LBUTTON&nFlags)
{
point.x -= 5;
point.y -= 10;
g_MouseRect[m_idetectnum-1].right=point.x/16*16;
g_MouseRect[m_idetectnum-1].bottom=point.y/16*16;
POINT tPoint=point;
g_ShowRect[m_idetectnum-1].right=tPoint.x/16*16;
g_ShowRect[m_idetectnum-1].bottom=tPoint.y/16*16;
}
}
CDialog::OnMouseMove(nFlags, point);
}
void CRemoteDetectConfig::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);
}
void CRemoteDetectConfig::OnMotionok()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
int i = 0,j = 0,k = 0;
if(!F_TimeTest())
return;
i = m_WeekDayCtrl.GetCurSel();
lpMotionDetect->struAlarmTime[i][0].byStartHour = m_iHour11;
lpMotionDetect->struAlarmTime[i][0].byStartMin = m_iMin11;
lpMotionDetect->struAlarmTime[i][0].byStopHour = m_iHour12;
lpMotionDetect->struAlarmTime[i][0].byStopMin = m_iMin12;
lpMotionDetect->struAlarmTime[i][1].byStartHour = m_iHour21;
lpMotionDetect->struAlarmTime[i][1].byStartMin = m_iMin21;
lpMotionDetect->struAlarmTime[i][1].byStopHour = m_iHour22;
lpMotionDetect->struAlarmTime[i][1].byStopMin = m_iMin22;
lpMotionDetect->struAlarmTime[i][2].byStartHour = m_iHour31;
lpMotionDetect->struAlarmTime[i][2].byStartMin = m_iMin31;
lpMotionDetect->struAlarmTime[i][2].byStopHour = m_iHour32;
lpMotionDetect->struAlarmTime[i][2].byStopMin = m_iMin32;
lpMotionDetect->struAlarmTime[i][3].byStartHour = m_iHour41;
lpMotionDetect->struAlarmTime[i][3].byStartMin = m_iMin41;
lpMotionDetect->struAlarmTime[i][3].byStopHour = m_iHour42;
lpMotionDetect->struAlarmTime[i][3].byStopMin = m_iMin42;
if(m_bSetMotion)
{
for(i = 0; i < 18; i++)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -