// ColorButton.cpp : implementation file // #include "stdafx.h" #include "newclient.h" #include "ColorButton.h" #include "MyOutput.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CMyOutput myoutput[MAXVIEWNUM]; extern WORD iActiveWndNumber; DWORD inumber = 0; ///////////////////////////////////////////////////////////////////////////// // CColorButton CColorButton::CColorButton() { m_iSubButtonNum = inumber++; } CColorButton::~CColorButton() { } BEGIN_MESSAGE_MAP(CColorButton, CButton) //{{AFX_MSG_MAP(CColorButton) ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CColorButton message handlers void CColorButton::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default StockHandle = myoutput[iActiveWndNumber].m_iPlayhandle; if(StockHandle>=0) { switch(m_iSubButtonNum) { case 0: //云台上 NET_DVR_PTZControl(StockHandle,TILT_UP,0); break; case 1: //云台下 NET_DVR_PTZControl(StockHandle,TILT_DOWN,0); break; case 2: //云台左 NET_DVR_PTZControl(StockHandle,PAN_LEFT,0); break; case 3: //云台右 NET_DVR_PTZControl(StockHandle,PAN_RIGHT,0); break; case 4: //调焦左 NET_DVR_PTZControl(StockHandle,ZOOM_IN,0); break; case 5: //调焦右 NET_DVR_PTZControl(StockHandle,ZOOM_OUT,0); break; case 6: //聚焦左 NET_DVR_PTZControl(StockHandle,FOCUS_NEAR,0); break; case 7: //聚焦右 NET_DVR_PTZControl(StockHandle,FOCUS_FAR,0); break; case 8: //光圈左 NET_DVR_PTZControl(StockHandle,IRIS_OPEN,0); break; case 9: //光圈右 NET_DVR_PTZControl(StockHandle,IRIS_CLOSE,0); break; default: break; } } CButton::OnLButtonDown(nFlags, point); } void CColorButton::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default StockHandle = myoutput[iActiveWndNumber].m_iPlayhandle; if(StockHandle>=0) { switch(m_iSubButtonNum) { case 0: //云台上 if(!NET_DVR_PTZControl(StockHandle,TILT_UP,1)) { TRACE("云台控制失败 %d", NET_DVR_GetLastError()); AfxMessageBox("云台控制失败"); } break; case 1: //云台下 if(!NET_DVR_PTZControl(StockHandle,TILT_DOWN,1)) AfxMessageBox("云台控制失败"); break; case 2: //云台左 if(!NET_DVR_PTZControl(StockHandle,PAN_LEFT,1)) AfxMessageBox("云台控制失败"); break; case 3: //云台右 if(!NET_DVR_PTZControl(StockHandle,PAN_RIGHT,1)) AfxMessageBox("云台控制失败"); break; case 4: //调焦左 if(!NET_DVR_PTZControl(StockHandle,ZOOM_IN,1)) AfxMessageBox("镜头控制失败"); break; case 5: //调焦右 if(!NET_DVR_PTZControl(StockHandle,ZOOM_OUT,1)) AfxMessageBox("镜头控制失败"); break; case 6: //聚焦左 if(!NET_DVR_PTZControl(StockHandle,FOCUS_NEAR,1)) AfxMessageBox("镜头控制失败"); break; case 7: //聚焦右 if(!NET_DVR_PTZControl(StockHandle,FOCUS_FAR,1)) AfxMessageBox("镜头控制失败"); break; case 8: //光圈左 if(!NET_DVR_PTZControl(StockHandle,IRIS_OPEN,1)) AfxMessageBox("镜头控制失败"); break; case 9: //光圈右 if(!NET_DVR_PTZControl(StockHandle,IRIS_CLOSE,1)) AfxMessageBox("镜头控制失败"); break; default: break; } } CButton::OnLButtonUp(nFlags, point); }