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

📄 remotehideconfig.cpp

📁 SDK DVR/DVS HIKVISION
💻 CPP
字号:
// RemoteHideConfig.cpp : implementation file
//

#include "stdafx.h"
#include "newclient.h"
#include "RemoteHideConfig.h"

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

/////////////////////////////////////////////////////////////////////////////
// CRemoteHideConfig dialog
RECT g_ShowRect1[MAX_SHELTERNUM];
RECT g_MouseRect1[MAX_SHELTERNUM];
int		m_idetectnum1 = 4;

void CALLBACK DrawFunShow1(long nPort,HDC hDc,DWORD nUser)
{
	CRect rect;
	int i = 0,j = 0;
	CPoint point;
	HBRUSH hBrush=::CreateSolidBrush(COLORREF(0xffffff));
	
	for (i=0; i<m_idetectnum1; i++)
	{
		rect.left = g_MouseRect1[i].left;
		rect.top = g_MouseRect1[i].top;
		rect.right = g_MouseRect1[i].right;
		rect.bottom = g_MouseRect1[i].bottom;
		::FillRect(hDc, &rect, hBrush);
		//::DrawEdge(hDc,&rect,BDR_SUNKENOUTER,BF_RECT);
	}
	SetBkMode(hDc,TRANSPARENT);
}

void CALLBACK DrawFun0(long nPort,HDC hDc,DWORD nUser)
{
	for (int i=0; i<m_idetectnum1; i++)
	{
		::DrawEdge(hDc,&g_ShowRect1[i],BDR_SUNKENOUTER,BF_RECT);
	}
	SetBkMode(hDc,TRANSPARENT);
}

CRemoteHideConfig::CRemoteHideConfig(CWnd* pParent /*=NULL*/)
	: CDialog(CRemoteHideConfig::IDD, pParent)
{
	//{{AFX_DATA_INIT(CRemoteHideConfig)
	m_bShowDetect = FALSE;
	m_bSetDetect = FALSE;
	//}}AFX_DATA_INIT
}


void CRemoteHideConfig::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CRemoteHideConfig)
	DDX_Control(pDX, IDC_DETECTPIC, m_DetectPic);
	DDX_Check(pDX, IDC_CHECKHIDEGETRECT, m_bShowDetect);
	DDX_Check(pDX, IDC_CHECKHIDESETRECT, m_bSetDetect);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CRemoteHideConfig, CDialog)
	//{{AFX_MSG_MAP(CRemoteHideConfig)
	ON_WM_LBUTTONDOWN()
	ON_WM_MOUSEMOVE()
	ON_BN_CLICKED(IDC_CHECKHIDEGETRECT, OnCheckhidegetrect)
	ON_BN_CLICKED(IDC_CHECKHIDESETRECT, OnCheckhidesetrect)
	ON_BN_CLICKED(IDEXIT, OnExit)
	ON_BN_CLICKED(IDHIDEOK, OnHideok)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRemoteHideConfig message handlers



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

	// TODO: Add extra initialization here
	int i;
	m_DetectPic.MoveWindow(7, 7, 352, 288);
	for(i=0; i<MAX_SHELTERNUM; i++)
	{
		g_MouseRect1[i].left = struShelter[i].wHideAreaTopLeftX/2;
		g_MouseRect1[i].top = struShelter[i].wHideAreaTopLeftY/2;
		g_MouseRect1[i].bottom = (struShelter[i].wHideAreaTopLeftY+struShelter[i].wHideAreaHeight)/2;
		g_MouseRect1[i].right = (struShelter[i].wHideAreaTopLeftX+struShelter[i].wHideAreaWidth)/2;
	}	
	NET_DVR_CLIENTINFO playstru;
	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;
	GetDlgItem(IDC_CHECKHIDEGETRECT)->EnableWindow(TRUE);
	GetDlgItem(IDC_CHECKHIDESETRECT)->EnableWindow(TRUE);	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CRemoteHideConfig::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, DrawFun0, 0);
			if (m_idetectnum1 >=MAX_SHELTERNUM)
				m_idetectnum1 = 0;
			point.x -= DETECTPICLEFT;
			point.y -= DETECTPICTOP;
			if (point.x < 0)
				point.x = 0;
			g_MouseRect1[m_idetectnum1].left=point.x/16*16;
			if (point.y < 0)
				point.y = 0;
			g_MouseRect1[m_idetectnum1].top=point.y/16*16;
			g_MouseRect1[m_idetectnum1].right=g_MouseRect1[m_idetectnum1].left;
			g_MouseRect1[m_idetectnum1].bottom=g_MouseRect1[m_idetectnum1].top;
			POINT tPoint=point;
			g_ShowRect1[m_idetectnum1].left=tPoint.x/16*16;
			g_ShowRect1[m_idetectnum1].top=tPoint.y/16*16;
			g_ShowRect1[m_idetectnum1].right=tPoint.x/16*16+1;
			g_ShowRect1[m_idetectnum1].bottom=tPoint.y/16*16+1;
			m_idetectnum1 ++;
		}
	}		
	CDialog::OnLButtonDown(nFlags, point);
}

void CRemoteHideConfig::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 -= DETECTPICLEFT;
			point.y -= DETECTPICTOP;
			if (point.x > 352)
				point.x = 352;
			g_MouseRect1[m_idetectnum1-1].right=point.x;
			if (point.y > 288)
				point.y = 288;
			g_MouseRect1[m_idetectnum1-1].bottom=point.y;
			POINT tPoint=point;
			g_ShowRect1[m_idetectnum1-1].right=tPoint.x;
			g_ShowRect1[m_idetectnum1-1].bottom=tPoint.y;
		}
	}		
	CDialog::OnMouseMove(nFlags, point);
}

void CRemoteHideConfig::OnCheckhidegetrect() 
{
	// 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);
		GetDlgItem(IDHIDEOK)->EnableWindow(FALSE);
	}
	if (m_bShowDetect)
	{
		NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL, 0);
		Sleep(200);
		NET_DVR_RigisterDrawFun(m_iPlayhandle,DrawFunShow1, 0);
	}
	else
	{
		NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL, 0);
	}
}

void CRemoteHideConfig::OnCheckhidesetrect() 
{
	// TODO: Add your control notification handler code here
	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_bDrawdetect = TRUE;
		m_idetectnum1 = 0;
		for(int i=0; i<MAX_SHELTERNUM; i++)
		{
			g_MouseRect1[i].left = 0;
			g_MouseRect1[i].top = 0;
			g_MouseRect1[i].bottom = 0;
			g_MouseRect1[i].right = 0;
		}
		GetDlgItem(IDHIDEOK)->EnableWindow(TRUE);
	}
	else
	{
		m_bDrawdetect = FALSE;
		NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL,0);
		GetDlgItem(IDHIDEOK)->EnableWindow(FALSE);
	}
}

void CRemoteHideConfig::OnExit() 
{
	// TODO: Add your control notification handler code here
	if(m_iPlayhandle >= 0)
	{
		NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL, 0);
		NET_DVR_StopRealPlay(m_iPlayhandle);
		m_iPlayhandle = -1;
	}
	CDialog::OnOK();
}

void CRemoteHideConfig::OnHideok() 
{
	// TODO: Add your control notification handler code here
	int k=0;
	for(k=0; k<MAX_SHELTERNUM; k++)
	{
		struShelter[k].wHideAreaTopLeftX = 0;
		struShelter[k].wHideAreaTopLeftY = 0;
		struShelter[k].wHideAreaWidth = 0;
		struShelter[k].wHideAreaHeight = 0;
	}
	for (k=0; k<m_idetectnum1; k++)
	{
		if (g_MouseRect1[k].top <= g_MouseRect1[k].bottom)
		{
			if(g_MouseRect1[k].left <= g_MouseRect1[k].right)
			{
				struShelter[k].wHideAreaTopLeftX = g_MouseRect1[k].left*2;
				struShelter[k].wHideAreaTopLeftY = g_MouseRect1[k].top*2;
				struShelter[k].wHideAreaWidth = (g_MouseRect1[k].right-g_MouseRect1[k].left)*2;
				struShelter[k].wHideAreaHeight = (g_MouseRect1[k].bottom-g_MouseRect1[k].top)*2;		
			}
			else
			{
				struShelter[k].wHideAreaTopLeftX = g_MouseRect1[k].right*2;
				struShelter[k].wHideAreaTopLeftY = g_MouseRect1[k].top*2;
				struShelter[k].wHideAreaWidth = (g_MouseRect1[k].left-g_MouseRect1[k].right)*2;
				struShelter[k].wHideAreaHeight = (g_MouseRect1[k].bottom-g_MouseRect1[k].top)*2;						
			}
		}
		else
		{
			if(g_MouseRect1[k].left <= g_MouseRect1[k].right)
			{
				struShelter[k].wHideAreaTopLeftX = g_MouseRect1[k].left*2;
				struShelter[k].wHideAreaTopLeftY = g_MouseRect1[k].bottom*2;
				struShelter[k].wHideAreaWidth = (g_MouseRect1[k].right-g_MouseRect1[k].left)*2;
				struShelter[k].wHideAreaHeight = (g_MouseRect1[k].top-g_MouseRect1[k].bottom)*2;
			}
			else
			{
				struShelter[k].wHideAreaTopLeftX = g_MouseRect1[k].right*2;
				struShelter[k].wHideAreaTopLeftY = g_MouseRect1[k].bottom*2;
				struShelter[k].wHideAreaWidth = (g_MouseRect1[k].left-g_MouseRect1[k].right)*2;
				struShelter[k].wHideAreaHeight = (g_MouseRect1[k].top-g_MouseRect1[k].bottom)*2;
			}
		}
	}
}

void CRemoteHideConfig::OnCancel() 
{
	// TODO: Add extra cleanup here
	
//	CDialog::OnCancel();
}

void CRemoteHideConfig::OnOK() 
{
	// TODO: Add extra cleanup here
	
	//	CDialog::OnOK();
}

⌨️ 快捷键说明

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