123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- // RemoteHideConfig.cpp : implementation file
- //
- #include "stdafx.h"
- #include "StoneU_HC_OCX.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(0xff00ff));
- 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,EDGE_SUNKEN,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(DETECTPICLEFT,DETECTPICTOP, 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("ÍøÂçÁ¬½Óʧ°Ü!");
- MessageBox(sTemp, "ÎÂܰÌáʾ", MB_ICONINFORMATION);
- }
- 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/16*16;
- if (point.y > 288)
- point.y = 288;
- g_MouseRect1[m_idetectnum1-1].bottom=point.y/16*16;
- POINT tPoint=point;
- g_ShowRect1[m_idetectnum1-1].right=tPoint.x/16*16;
- g_ShowRect1[m_idetectnum1-1].bottom=tPoint.y/16*16;
- }
- }
- 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();
- }
|