ColorButton.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // ColorButton.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "newclient.h"
  5. #include "ColorButton.h"
  6. #include "MyOutput.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. extern CMyOutput myoutput[MAXVIEWNUM];
  13. extern WORD iActiveWndNumber;
  14. DWORD inumber = 0;
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CColorButton
  17. CColorButton::CColorButton()
  18. {
  19. m_iSubButtonNum = inumber++;
  20. }
  21. CColorButton::~CColorButton()
  22. {
  23. }
  24. BEGIN_MESSAGE_MAP(CColorButton, CButton)
  25. //{{AFX_MSG_MAP(CColorButton)
  26. ON_WM_LBUTTONDOWN()
  27. ON_WM_LBUTTONUP()
  28. //}}AFX_MSG_MAP
  29. END_MESSAGE_MAP()
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CColorButton message handlers
  32. void CColorButton::OnLButtonDown(UINT nFlags, CPoint point)
  33. {
  34. // TODO: Add your message handler code here and/or call default
  35. StockHandle = myoutput[iActiveWndNumber].m_iPlayhandle;
  36. if(StockHandle>=0)
  37. {
  38. switch(m_iSubButtonNum)
  39. {
  40. case 0: //云台上
  41. NET_DVR_PTZControl(StockHandle,TILT_UP,0);
  42. break;
  43. case 1: //云台下
  44. NET_DVR_PTZControl(StockHandle,TILT_DOWN,0);
  45. break;
  46. case 2: //云台左
  47. NET_DVR_PTZControl(StockHandle,PAN_LEFT,0);
  48. break;
  49. case 3: //云台右
  50. NET_DVR_PTZControl(StockHandle,PAN_RIGHT,0);
  51. break;
  52. case 4: //调焦左
  53. NET_DVR_PTZControl(StockHandle,ZOOM_IN,0);
  54. break;
  55. case 5: //调焦右
  56. NET_DVR_PTZControl(StockHandle,ZOOM_OUT,0);
  57. break;
  58. case 6: //聚焦左
  59. NET_DVR_PTZControl(StockHandle,FOCUS_NEAR,0);
  60. break;
  61. case 7: //聚焦右
  62. NET_DVR_PTZControl(StockHandle,FOCUS_FAR,0);
  63. break;
  64. case 8: //光圈左
  65. NET_DVR_PTZControl(StockHandle,IRIS_OPEN,0);
  66. break;
  67. case 9: //光圈右
  68. NET_DVR_PTZControl(StockHandle,IRIS_CLOSE,0);
  69. break;
  70. default:
  71. break;
  72. }
  73. }
  74. CButton::OnLButtonDown(nFlags, point);
  75. }
  76. void CColorButton::OnLButtonUp(UINT nFlags, CPoint point)
  77. {
  78. // TODO: Add your message handler code here and/or call default
  79. StockHandle = myoutput[iActiveWndNumber].m_iPlayhandle;
  80. if(StockHandle>=0)
  81. {
  82. switch(m_iSubButtonNum)
  83. {
  84. case 0: //云台上
  85. if(!NET_DVR_PTZControl(StockHandle,TILT_UP,1))
  86. {
  87. TRACE("云台控制失败 %d", NET_DVR_GetLastError());
  88. AfxMessageBox("云台控制失败");
  89. }
  90. break;
  91. case 1: //云台下
  92. if(!NET_DVR_PTZControl(StockHandle,TILT_DOWN,1))
  93. AfxMessageBox("云台控制失败");
  94. break;
  95. case 2: //云台左
  96. if(!NET_DVR_PTZControl(StockHandle,PAN_LEFT,1))
  97. AfxMessageBox("云台控制失败");
  98. break;
  99. case 3: //云台右
  100. if(!NET_DVR_PTZControl(StockHandle,PAN_RIGHT,1))
  101. AfxMessageBox("云台控制失败");
  102. break;
  103. case 4: //调焦左
  104. if(!NET_DVR_PTZControl(StockHandle,ZOOM_IN,1))
  105. AfxMessageBox("镜头控制失败");
  106. break;
  107. case 5: //调焦右
  108. if(!NET_DVR_PTZControl(StockHandle,ZOOM_OUT,1))
  109. AfxMessageBox("镜头控制失败");
  110. break;
  111. case 6: //聚焦左
  112. if(!NET_DVR_PTZControl(StockHandle,FOCUS_NEAR,1))
  113. AfxMessageBox("镜头控制失败");
  114. break;
  115. case 7: //聚焦右
  116. if(!NET_DVR_PTZControl(StockHandle,FOCUS_FAR,1))
  117. AfxMessageBox("镜头控制失败");
  118. break;
  119. case 8: //光圈左
  120. if(!NET_DVR_PTZControl(StockHandle,IRIS_OPEN,1))
  121. AfxMessageBox("镜头控制失败");
  122. break;
  123. case 9: //光圈右
  124. if(!NET_DVR_PTZControl(StockHandle,IRIS_CLOSE,1))
  125. AfxMessageBox("镜头控制失败");
  126. break;
  127. default:
  128. break;
  129. }
  130. }
  131. CButton::OnLButtonUp(nFlags, point);
  132. }