RemoteHideConfig.cpp 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. // RemoteHideConfig.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "StoneU_HC_OCX.h"
  5. #include "RemoteHideConfig.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CRemoteHideConfig dialog
  13. RECT g_ShowRect1[MAX_SHELTERNUM];
  14. RECT g_MouseRect1[MAX_SHELTERNUM];
  15. int m_idetectnum1 = 4;
  16. void CALLBACK DrawFunShow1(long nPort,HDC hDc,DWORD nUser)
  17. {
  18. CRect rect;
  19. int i = 0,j = 0;
  20. CPoint point;
  21. HBRUSH hBrush=::CreateSolidBrush(COLORREF(0xff00ff));
  22. for (i=0; i<m_idetectnum1; i++)
  23. {
  24. rect.left = g_MouseRect1[i].left;
  25. rect.top = g_MouseRect1[i].top;
  26. rect.right = g_MouseRect1[i].right;
  27. rect.bottom = g_MouseRect1[i].bottom;
  28. ::FillRect(hDc, &rect, hBrush);
  29. ::DrawEdge(hDc,&rect,EDGE_SUNKEN,BF_RECT);
  30. }
  31. SetBkMode(hDc,TRANSPARENT);
  32. }
  33. void CALLBACK DrawFun0(long nPort,HDC hDc,DWORD nUser)
  34. {
  35. for (int i=0; i<m_idetectnum1; i++)
  36. {
  37. ::DrawEdge(hDc,&g_ShowRect1[i],BDR_SUNKENOUTER,BF_RECT);
  38. }
  39. SetBkMode(hDc,TRANSPARENT);
  40. }
  41. CRemoteHideConfig::CRemoteHideConfig(CWnd* pParent /*=NULL*/)
  42. : CDialog(CRemoteHideConfig::IDD, pParent)
  43. {
  44. //{{AFX_DATA_INIT(CRemoteHideConfig)
  45. m_bShowDetect = FALSE;
  46. m_bSetDetect = FALSE;
  47. //}}AFX_DATA_INIT
  48. }
  49. void CRemoteHideConfig::DoDataExchange(CDataExchange* pDX)
  50. {
  51. CDialog::DoDataExchange(pDX);
  52. //{{AFX_DATA_MAP(CRemoteHideConfig)
  53. DDX_Control(pDX, IDC_DETECTPIC, m_DetectPic);
  54. DDX_Check(pDX, IDC_CHECKHIDEGETRECT, m_bShowDetect);
  55. DDX_Check(pDX, IDC_CHECKHIDESETRECT, m_bSetDetect);
  56. //}}AFX_DATA_MAP
  57. }
  58. BEGIN_MESSAGE_MAP(CRemoteHideConfig, CDialog)
  59. //{{AFX_MSG_MAP(CRemoteHideConfig)
  60. ON_WM_LBUTTONDOWN()
  61. ON_WM_MOUSEMOVE()
  62. ON_BN_CLICKED(IDC_CHECKHIDEGETRECT, OnCheckhidegetrect)
  63. ON_BN_CLICKED(IDC_CHECKHIDESETRECT, OnCheckhidesetrect)
  64. ON_BN_CLICKED(IDEXIT, OnExit)
  65. ON_BN_CLICKED(IDHIDEOK, OnHideok)
  66. //}}AFX_MSG_MAP
  67. END_MESSAGE_MAP()
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CRemoteHideConfig message handlers
  70. BOOL CRemoteHideConfig::OnInitDialog()
  71. {
  72. CDialog::OnInitDialog();
  73. // TODO: Add extra initialization here
  74. int i;
  75. m_DetectPic.MoveWindow(DETECTPICLEFT,DETECTPICTOP, 352, 288);
  76. for(i=0; i<MAX_SHELTERNUM; i++)
  77. {
  78. g_MouseRect1[i].left = struShelter[i].wHideAreaTopLeftX/2;
  79. g_MouseRect1[i].top = struShelter[i].wHideAreaTopLeftY/2;
  80. g_MouseRect1[i].bottom = (struShelter[i].wHideAreaTopLeftY+struShelter[i].wHideAreaHeight)/2;
  81. g_MouseRect1[i].right = (struShelter[i].wHideAreaTopLeftX+struShelter[i].wHideAreaWidth)/2;
  82. }
  83. NET_DVR_CLIENTINFO playstru;
  84. playstru.hPlayWnd = m_DetectPic.GetSafeHwnd();
  85. playstru.lChannel = m_iChannel;
  86. playstru.lLinkMode = 0;
  87. playstru.sMultiCastIP = "";
  88. m_iPlayhandle = NET_DVR_RealPlay(m_lServerID, &playstru);
  89. if(m_iPlayhandle == -1)
  90. {
  91. CString sTemp;
  92. sTemp.Format("ÍøÂçÁ¬½Óʧ°Ü!");
  93. MessageBox(sTemp, "ÎÂܰÌáʾ", MB_ICONINFORMATION);
  94. }
  95. m_bDrawdetect = FALSE;
  96. GetDlgItem(IDC_CHECKHIDEGETRECT)->EnableWindow(TRUE);
  97. GetDlgItem(IDC_CHECKHIDESETRECT)->EnableWindow(TRUE);
  98. return TRUE; // return TRUE unless you set the focus to a control
  99. // EXCEPTION: OCX Property Pages should return FALSE
  100. }
  101. void CRemoteHideConfig::OnLButtonDown(UINT nFlags, CPoint point)
  102. {
  103. // TODO: Add your message handler code here and/or call default
  104. if (m_bDrawdetect)
  105. {
  106. if (MK_CONTROL&nFlags)
  107. {
  108. NET_DVR_RigisterDrawFun(m_iPlayhandle, DrawFun0, 0);
  109. if (m_idetectnum1 >=MAX_SHELTERNUM)
  110. m_idetectnum1 = 0;
  111. point.x -= DETECTPICLEFT;
  112. point.y -= DETECTPICTOP;
  113. if (point.x < 0)
  114. point.x = 0;
  115. g_MouseRect1[m_idetectnum1].left=point.x/16*16;
  116. if (point.y < 0)
  117. point.y = 0;
  118. g_MouseRect1[m_idetectnum1].top=point.y/16*16;
  119. g_MouseRect1[m_idetectnum1].right=g_MouseRect1[m_idetectnum1].left;
  120. g_MouseRect1[m_idetectnum1].bottom=g_MouseRect1[m_idetectnum1].top;
  121. POINT tPoint=point;
  122. g_ShowRect1[m_idetectnum1].left=tPoint.x/16*16;
  123. g_ShowRect1[m_idetectnum1].top=tPoint.y/16*16;
  124. g_ShowRect1[m_idetectnum1].right=tPoint.x/16*16+1;
  125. g_ShowRect1[m_idetectnum1].bottom=tPoint.y/16*16+1;
  126. m_idetectnum1 ++;
  127. }
  128. }
  129. CDialog::OnLButtonDown(nFlags, point);
  130. }
  131. void CRemoteHideConfig::OnMouseMove(UINT nFlags, CPoint point)
  132. {
  133. // TODO: Add your message handler code here and/or call default
  134. if (m_bDrawdetect)
  135. {
  136. if (MK_CONTROL&nFlags&&MK_LBUTTON&nFlags)
  137. {
  138. point.x -= DETECTPICLEFT;
  139. point.y -= DETECTPICTOP;
  140. if (point.x > 352)
  141. point.x = 352;
  142. g_MouseRect1[m_idetectnum1-1].right=point.x/16*16;
  143. if (point.y > 288)
  144. point.y = 288;
  145. g_MouseRect1[m_idetectnum1-1].bottom=point.y/16*16;
  146. POINT tPoint=point;
  147. g_ShowRect1[m_idetectnum1-1].right=tPoint.x/16*16;
  148. g_ShowRect1[m_idetectnum1-1].bottom=tPoint.y/16*16;
  149. }
  150. }
  151. CDialog::OnMouseMove(nFlags, point);
  152. }
  153. void CRemoteHideConfig::OnCheckhidegetrect()
  154. {
  155. // TODO: Add your control notification handler code here
  156. if (m_iPlayhandle < 0)
  157. return;
  158. UpdateData(TRUE);
  159. if (m_bSetDetect)
  160. {
  161. m_bSetDetect = FALSE;
  162. m_bDrawdetect = FALSE;
  163. UpdateData(FALSE);
  164. GetDlgItem(IDHIDEOK)->EnableWindow(FALSE);
  165. }
  166. if (m_bShowDetect)
  167. {
  168. NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL, 0);
  169. Sleep(200);
  170. NET_DVR_RigisterDrawFun(m_iPlayhandle,DrawFunShow1, 0);
  171. }
  172. else
  173. {
  174. NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL, 0);
  175. }
  176. }
  177. void CRemoteHideConfig::OnCheckhidesetrect()
  178. {
  179. // TODO: Add your control notification handler code here
  180. if (m_iPlayhandle < 0)
  181. return;
  182. UpdateData(TRUE);
  183. if (m_bShowDetect)
  184. {
  185. m_bShowDetect = FALSE;
  186. UpdateData(FALSE);
  187. }
  188. if (m_bSetDetect)
  189. {
  190. NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL,0);
  191. m_bDrawdetect = TRUE;
  192. m_idetectnum1 = 0;
  193. for(int i=0; i<MAX_SHELTERNUM; i++)
  194. {
  195. g_MouseRect1[i].left = 0;
  196. g_MouseRect1[i].top = 0;
  197. g_MouseRect1[i].bottom = 0;
  198. g_MouseRect1[i].right = 0;
  199. }
  200. GetDlgItem(IDHIDEOK)->EnableWindow(TRUE);
  201. }
  202. else
  203. {
  204. m_bDrawdetect = FALSE;
  205. NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL,0);
  206. GetDlgItem(IDHIDEOK)->EnableWindow(FALSE);
  207. }
  208. }
  209. void CRemoteHideConfig::OnExit()
  210. {
  211. // TODO: Add your control notification handler code here
  212. if (m_iPlayhandle >= 0)
  213. {
  214. NET_DVR_RigisterDrawFun(m_iPlayhandle,NULL, 0);
  215. NET_DVR_StopRealPlay(m_iPlayhandle);
  216. m_iPlayhandle = -1;
  217. }
  218. CDialog::OnOK();
  219. }
  220. void CRemoteHideConfig::OnHideok()
  221. {
  222. // TODO: Add your control notification handler code here
  223. int k=0;
  224. for(k=0; k<MAX_SHELTERNUM; k++)
  225. {
  226. struShelter[k].wHideAreaTopLeftX = 0;
  227. struShelter[k].wHideAreaTopLeftY = 0;
  228. struShelter[k].wHideAreaWidth = 0;
  229. struShelter[k].wHideAreaHeight = 0;
  230. }
  231. for (k=0; k<m_idetectnum1; k++)
  232. {
  233. if (g_MouseRect1[k].top <= g_MouseRect1[k].bottom)
  234. {
  235. if(g_MouseRect1[k].left <= g_MouseRect1[k].right)
  236. {
  237. struShelter[k].wHideAreaTopLeftX = g_MouseRect1[k].left*2;
  238. struShelter[k].wHideAreaTopLeftY = g_MouseRect1[k].top*2;
  239. struShelter[k].wHideAreaWidth = (g_MouseRect1[k].right-g_MouseRect1[k].left)*2;
  240. struShelter[k].wHideAreaHeight = (g_MouseRect1[k].bottom-g_MouseRect1[k].top)*2;
  241. }
  242. else
  243. {
  244. struShelter[k].wHideAreaTopLeftX = g_MouseRect1[k].right*2;
  245. struShelter[k].wHideAreaTopLeftY = g_MouseRect1[k].top*2;
  246. struShelter[k].wHideAreaWidth = (g_MouseRect1[k].left-g_MouseRect1[k].right)*2;
  247. struShelter[k].wHideAreaHeight = (g_MouseRect1[k].bottom-g_MouseRect1[k].top)*2;
  248. }
  249. }
  250. else
  251. {
  252. if(g_MouseRect1[k].left <= g_MouseRect1[k].right)
  253. {
  254. struShelter[k].wHideAreaTopLeftX = g_MouseRect1[k].left*2;
  255. struShelter[k].wHideAreaTopLeftY = g_MouseRect1[k].bottom*2;
  256. struShelter[k].wHideAreaWidth = (g_MouseRect1[k].right-g_MouseRect1[k].left)*2;
  257. struShelter[k].wHideAreaHeight = (g_MouseRect1[k].top-g_MouseRect1[k].bottom)*2;
  258. }
  259. else
  260. {
  261. struShelter[k].wHideAreaTopLeftX = g_MouseRect1[k].right*2;
  262. struShelter[k].wHideAreaTopLeftY = g_MouseRect1[k].bottom*2;
  263. struShelter[k].wHideAreaWidth = (g_MouseRect1[k].left-g_MouseRect1[k].right)*2;
  264. struShelter[k].wHideAreaHeight = (g_MouseRect1[k].top-g_MouseRect1[k].bottom)*2;
  265. }
  266. }
  267. }
  268. }
  269. void CRemoteHideConfig::OnCancel()
  270. {
  271. // TODO: Add extra cleanup here
  272. // CDialog::OnCancel();
  273. }