remotehideconfig.cpp

来自「监控开发资料,提供二次开发源码和使用说明书」· C++ 代码 · 共 235 行

CPP
235
字号
// 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;
RECT g_MouseRect1;

void CALLBACK DrawFunShow1(long nPort,HDC hDc,DWORD nUser)
{
	CRect rect;
	int i = 0,j = 0;
	CPoint point;

	rect.left = g_MouseRect1.left;
	rect.top = g_MouseRect1.top;
	rect.right = g_MouseRect1.right;
	rect.bottom = g_MouseRect1.bottom;
	HBRUSH hBrush=::CreateSolidBrush(COLORREF(0xffffff));
	::FillRect(hDc, &rect, hBrush);
	SetBkMode(hDc,TRANSPARENT);
}

void CALLBACK DrawFun0(long nPort,HDC hDc,DWORD nUser)
{
	::DrawEdge(hDc,&g_ShowRect1,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
	m_DetectPic.MoveWindow(DETECTPICLEFT,DETECTPICTOP, 352, 288);
	g_MouseRect1.left = m_wHideX/2;
	g_MouseRect1.top = m_wHideY/2;
	g_MouseRect1.bottom = (m_wHideY + m_wHideHeight)/2;
	g_MouseRect1.right = (m_wHideX + m_wHideWidth)/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("网络连接失败!");
		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);
			point.x -= DETECTPICLEFT;
			point.y -= DETECTPICTOP;
			if(point.x < 0)
				point.x = 0;
			g_MouseRect1.left=point.x;
			if(point.y < 0)
				point.y = 0;
			g_MouseRect1.top=point.y;
			g_MouseRect1.right=g_MouseRect1.left;
			g_MouseRect1.bottom=g_MouseRect1.top;
			POINT tPoint=point;
			g_ShowRect1.left=tPoint.x;
			g_ShowRect1.top=tPoint.y;
			g_ShowRect1.right=tPoint.x+1;
			g_ShowRect1.bottom=tPoint.y+1;
		}
	}	
	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 > 704)
				point.x = 704;
			g_MouseRect1.right=point.x;
			if(point.y > 576)
				point.y = 576;
			g_MouseRect1.bottom=point.y;
			POINT tPoint=point;
			g_ShowRect1.right=tPoint.x;
			g_ShowRect1.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;
		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
	m_wHideX = (WORD)(g_MouseRect1.left*2);
	m_wHideY = (WORD)(g_MouseRect1.top*2);
	m_wHideWidth = (WORD)((g_MouseRect1.right-g_MouseRect1.left)*2);
	m_wHideHeight = (WORD)((g_MouseRect1.bottom-g_MouseRect1.top)*2);
}

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

⌨️ 快捷键说明

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