SetAlarm.cpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. // SetAlarm.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "StoneU_HC_OCX.h"
  5. #include "SetAlarm.h"
  6. #include "mdlProject.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CSetAlarm dialog
  14. CSetAlarm::CSetAlarm(CWnd* pParent /*=NULL*/)
  15. : CDialog(CSetAlarm::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CSetAlarm)
  18. // NOTE: the ClassWizard will add member initialization here
  19. //}}AFX_DATA_INIT
  20. }
  21. void CSetAlarm::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(CSetAlarm)
  25. DDX_Control(pDX, IDC_TREEALARM, m_tree);
  26. //}}AFX_DATA_MAP
  27. }
  28. BEGIN_MESSAGE_MAP(CSetAlarm, CDialog)
  29. //{{AFX_MSG_MAP(CSetAlarm)
  30. ON_BN_CLICKED(IDC_SELALL, OnSelall)
  31. ON_BN_CLICKED(IDC_NOALL, OnNoall)
  32. ON_NOTIFY(NM_CLICK, IDC_TREEALARM, OnClickTreealarm)
  33. ON_NOTIFY(NM_DBLCLK, IDC_TREEALARM, OnDblclkTreealarm)
  34. ON_NOTIFY(TVN_SELCHANGED, IDC_TREEALARM, OnSelchangedTreealarm)
  35. ON_NOTIFY(TVN_SELCHANGING, IDC_TREEALARM, OnSelchangingTreealarm)
  36. ON_BN_CLICKED(IDC_EXIT, OnExit)
  37. ON_BN_CLICKED(IDCSETALARMOK, OnCsetalarmok)
  38. ON_BN_CLICKED(ID_CANCEL, OnCancel)
  39. //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CSetAlarm message handlers
  43. BOOL CSetAlarm::OnInitDialog()
  44. {
  45. CDialog::OnInitDialog();
  46. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();
  47. CBitmap bmp[2];
  48. // TODO: Add extra initialization here
  49. m_bOK = FALSE;
  50. m_imagelist.Create(16,16,TRUE,1,1);
  51. bmp[0].LoadBitmap(IDB_UCHK);
  52. m_imagelist.Add(&bmp[0],RGB(0,0,0));
  53. bmp[1].LoadBitmap(IDB_CHK);
  54. m_imagelist.Add(&bmp[1],RGB(0,0,0));
  55. m_tree.SetImageList(&m_imagelist,TVSIL_NORMAL);
  56. for(int i = 0; i < MAXIPNUMBER; i++)
  57. {
  58. if(pDlg->m_Serverinfo[i].m_iServerChannelNumber >= 0)
  59. {
  60. F_AddNode(i);
  61. }
  62. }
  63. F_CheckNode();
  64. return TRUE; // return TRUE unless you set the focus to a control
  65. // EXCEPTION: OCX Property Pages should return FALSE
  66. }
  67. void CSetAlarm::OnSelall()
  68. {
  69. // TODO: Add your control notification handler code here
  70. HTREEITEM node1;
  71. node1=m_tree.GetRootItem();
  72. while (node1!=NULL)
  73. {
  74. m_tree.SetItemImage(node1,1,1);
  75. node1=m_tree.GetNextSiblingItem(node1);
  76. }
  77. }
  78. void CSetAlarm::OnNoall()
  79. {
  80. // TODO: Add your control notification handler code here
  81. HTREEITEM node1;
  82. node1=m_tree.GetRootItem();
  83. while (node1!=NULL)
  84. {
  85. m_tree.SetItemImage(node1,0,0);
  86. node1=m_tree.GetNextSiblingItem(node1);
  87. }
  88. }
  89. void CSetAlarm::F_AddNode(int ipnum)
  90. {
  91. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  92. //CNewclientDlg *pDlg = g_pOCXCtrl[nIndex]->m_pDlgMain;//(CNewclientDlg *)this->GetParent();
  93. //HTREEITEM node1;
  94. //CString sTemp;
  95. //node1=m_tree.GetRootItem();
  96. //while (node1!=NULL)
  97. //{
  98. // sTemp=m_tree.GetItemText(node1);
  99. // sTemp=sTemp.Left(sTemp.Find("("));
  100. // if (pDlg->m_Serverinfo[ipnum].m_csServerIP == sTemp)
  101. // {
  102. // return;
  103. // }
  104. // node1=m_tree.GetNextSiblingItem(node1);
  105. //
  106. //}
  107. //sTemp.Format("%s(%s)----对应报警灯%d",pDlg->m_Serverinfo[ipnum].m_csServerName,pDlg->m_Serverinfo[ipnum].m_csServerIP, ipnum+1);
  108. //node1=m_tree.InsertItem(_T(sTemp),0,0,TVI_ROOT);
  109. //m_tree.SetItemData(node1,ipnum);
  110. //m_tree.Expand(node1,TVE_EXPAND);
  111. }
  112. void CSetAlarm::F_CheckNode()
  113. {
  114. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  115. //CNewclientDlg *pDlg = g_pOCXCtrl[nIndex]->m_pDlgMain;//(CNewclientDlg *)this->GetParent();
  116. //HTREEITEM node1;
  117. //int i;
  118. //node1=m_tree.GetRootItem();
  119. //while (node1!=NULL)
  120. //{
  121. // i = m_tree.GetItemData(node1);
  122. // if(pDlg->m_ClientParam.m_iAlarmHandle[i] != -1)
  123. // m_tree.SetItemImage(node1,1,1);
  124. // node1=m_tree.GetNextSiblingItem(node1);
  125. //}
  126. }
  127. void CSetAlarm::OnClickTreealarm(NMHDR* pNMHDR, LRESULT* pResult)
  128. {
  129. // TODO: Add your control notification handler code here
  130. HTREEITEM node1;
  131. int imageindex,selectindex;
  132. node1=m_tree.GetSelectedItem();
  133. if (node1==m_nSelItem)
  134. {
  135. *pResult = 0;
  136. return;
  137. }
  138. m_tree.GetItemImage(node1,imageindex,selectindex);
  139. if (imageindex==1)
  140. {
  141. m_tree.SetItemImage(node1,0,0);
  142. }else
  143. {
  144. m_tree.SetItemImage(node1,1,1);
  145. }
  146. *pResult = 0;
  147. }
  148. void CSetAlarm::OnDblclkTreealarm(NMHDR* pNMHDR, LRESULT* pResult)
  149. {
  150. // TODO: Add your control notification handler code here
  151. HTREEITEM node1;
  152. int imageindex,selectindex;
  153. node1=m_tree.GetSelectedItem();
  154. m_tree.GetItemImage(node1,imageindex,selectindex);
  155. if (imageindex==1)
  156. {
  157. m_tree.SetItemImage(node1,0,0);
  158. }else
  159. {
  160. m_tree.SetItemImage(node1,1,1);
  161. }
  162. *pResult = 0;
  163. }
  164. void CSetAlarm::OnSelchangedTreealarm(NMHDR* pNMHDR, LRESULT* pResult)
  165. {
  166. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  167. // TODO: Add your control notification handler code here
  168. HTREEITEM node1;
  169. int imageindex,selectindex;
  170. node1=m_tree.GetSelectedItem();
  171. if (node1==m_nSelItem)
  172. {
  173. *pResult = 0;
  174. return;
  175. }
  176. m_tree.GetItemImage(node1,imageindex,selectindex);
  177. if (imageindex==1)
  178. {
  179. m_tree.SetItemImage(node1,0,0);
  180. }else
  181. {
  182. m_tree.SetItemImage(node1,1,1);
  183. }
  184. *pResult = 0;
  185. }
  186. void CSetAlarm::OnSelchangingTreealarm(NMHDR* pNMHDR, LRESULT* pResult)
  187. {
  188. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  189. // TODO: Add your control notification handler code here
  190. int imageindex,selectindex;
  191. m_nSelItem=m_tree.GetSelectedItem();
  192. m_tree.GetItemImage(m_nSelItem,imageindex,selectindex);
  193. if (imageindex==1)
  194. {
  195. m_tree.SetItemImage(m_nSelItem,0,0);
  196. }else
  197. {
  198. m_tree.SetItemImage(m_nSelItem,1,1);
  199. }
  200. *pResult = 0;
  201. }
  202. void CSetAlarm::OnExit()
  203. {
  204. // TODO: Add your control notification handler code here
  205. CDialog::OnCancel();
  206. }
  207. void CSetAlarm::OnCsetalarmok()
  208. {
  209. // TODO: Add your control notification handler code here
  210. //HTREEITEM node1;
  211. //int imageindex,selectindex;
  212. //int ipnum;
  213. //CString sTemp;
  214. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  215. //CNewclientDlg *pDlg = g_pOCXCtrl[nIndex]->m_pDlgMain;//(CNewclientDlg *)this->GetParent();
  216. //
  217. //node1=m_tree.GetRootItem();
  218. //while(node1!=NULL)
  219. //{
  220. // m_tree.GetItemImage(node1,imageindex,selectindex);
  221. // ipnum=m_tree.GetItemData(node1);
  222. //
  223. // if(imageindex==1)
  224. // {
  225. // if(pDlg->m_ClientParam.m_iAlarmHandle[ipnum] == -1)
  226. // {
  227. // pDlg->m_ClientParam.m_iAlarmHandle[ipnum] = NET_DVR_SetupAlarmChan(pDlg->m_Serverinfo[ipnum].m_lServerID);
  228. // if(pDlg->m_ClientParam.m_iAlarmHandle[ipnum] == -1)
  229. // {
  230. // m_tree.SetItemImage(node1,0,0);
  231. // sTemp.Format("%s报警设防失败 lasterror = %d!",pDlg->m_Serverinfo[ipnum].m_csServerName, NET_DVR_GetLastError());
  232. // MessageBox(sTemp, "温馨提示", MB_ICONINFORMATION);
  233. // }
  234. // }
  235. // }
  236. // else
  237. // {
  238. // if(pDlg->m_ClientParam.m_iAlarmHandle[ipnum] >= 0)
  239. // {
  240. // if(NET_DVR_CloseAlarmChan(pDlg->m_ClientParam.m_iAlarmHandle[ipnum]))
  241. // {
  242. // pDlg->m_ClientParam.m_iAlarmHandle[ipnum] = -1;
  243. // }
  244. // else
  245. // {
  246. // m_tree.SetItemImage(node1,1,1);
  247. // sTemp.Format("%s报警撤防失败! lasterror = %d ",pDlg->m_Serverinfo[ipnum].m_csServerName, NET_DVR_GetLastError());
  248. // MessageBox(sTemp, "温馨提示", MB_ICONINFORMATION);
  249. // }
  250. // }
  251. // }
  252. // node1=m_tree.GetNextSiblingItem(node1);
  253. //}
  254. //m_bOK = TRUE;
  255. //
  256. //MessageBox("布防撤防完成!", "温馨提示", MB_ICONINFORMATION);
  257. }
  258. void CSetAlarm::OnCancel()
  259. {
  260. // TODO: Add your control notification handler code here
  261. }