// SetAlarm.cpp : implementation file // #include "stdafx.h" #include "StoneU_HC_OCX.h" #include "SetAlarm.h" #include "mdlProject.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSetAlarm dialog CSetAlarm::CSetAlarm(CWnd* pParent /*=NULL*/) : CDialog(CSetAlarm::IDD, pParent) { //{{AFX_DATA_INIT(CSetAlarm) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CSetAlarm::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSetAlarm) DDX_Control(pDX, IDC_TREEALARM, m_tree); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSetAlarm, CDialog) //{{AFX_MSG_MAP(CSetAlarm) ON_BN_CLICKED(IDC_SELALL, OnSelall) ON_BN_CLICKED(IDC_NOALL, OnNoall) ON_NOTIFY(NM_CLICK, IDC_TREEALARM, OnClickTreealarm) ON_NOTIFY(NM_DBLCLK, IDC_TREEALARM, OnDblclkTreealarm) ON_NOTIFY(TVN_SELCHANGED, IDC_TREEALARM, OnSelchangedTreealarm) ON_NOTIFY(TVN_SELCHANGING, IDC_TREEALARM, OnSelchangingTreealarm) ON_BN_CLICKED(IDC_EXIT, OnExit) ON_BN_CLICKED(IDCSETALARMOK, OnCsetalarmok) ON_BN_CLICKED(ID_CANCEL, OnCancel) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSetAlarm message handlers BOOL CSetAlarm::OnInitDialog() { CDialog::OnInitDialog(); CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent(); CBitmap bmp[2]; // TODO: Add extra initialization here m_bOK = FALSE; m_imagelist.Create(16,16,TRUE,1,1); bmp[0].LoadBitmap(IDB_UCHK); m_imagelist.Add(&bmp[0],RGB(0,0,0)); bmp[1].LoadBitmap(IDB_CHK); m_imagelist.Add(&bmp[1],RGB(0,0,0)); m_tree.SetImageList(&m_imagelist,TVSIL_NORMAL); for(int i = 0; i < MAXIPNUMBER; i++) { if(pDlg->m_Serverinfo[i].m_iServerChannelNumber >= 0) { F_AddNode(i); } } F_CheckNode(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CSetAlarm::OnSelall() { // TODO: Add your control notification handler code here HTREEITEM node1; node1=m_tree.GetRootItem(); while (node1!=NULL) { m_tree.SetItemImage(node1,1,1); node1=m_tree.GetNextSiblingItem(node1); } } void CSetAlarm::OnNoall() { // TODO: Add your control notification handler code here HTREEITEM node1; node1=m_tree.GetRootItem(); while (node1!=NULL) { m_tree.SetItemImage(node1,0,0); node1=m_tree.GetNextSiblingItem(node1); } } void CSetAlarm::F_AddNode(int ipnum) { //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber ); //CNewclientDlg *pDlg = g_pOCXCtrl[nIndex]->m_pDlgMain;//(CNewclientDlg *)this->GetParent(); //HTREEITEM node1; //CString sTemp; //node1=m_tree.GetRootItem(); //while (node1!=NULL) //{ // sTemp=m_tree.GetItemText(node1); // sTemp=sTemp.Left(sTemp.Find("(")); // if (pDlg->m_Serverinfo[ipnum].m_csServerIP == sTemp) // { // return; // } // node1=m_tree.GetNextSiblingItem(node1); // //} //sTemp.Format("%s(%s)----对应报警灯%d",pDlg->m_Serverinfo[ipnum].m_csServerName,pDlg->m_Serverinfo[ipnum].m_csServerIP, ipnum+1); //node1=m_tree.InsertItem(_T(sTemp),0,0,TVI_ROOT); //m_tree.SetItemData(node1,ipnum); //m_tree.Expand(node1,TVE_EXPAND); } void CSetAlarm::F_CheckNode() { //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber ); //CNewclientDlg *pDlg = g_pOCXCtrl[nIndex]->m_pDlgMain;//(CNewclientDlg *)this->GetParent(); //HTREEITEM node1; //int i; //node1=m_tree.GetRootItem(); //while (node1!=NULL) //{ // i = m_tree.GetItemData(node1); // if(pDlg->m_ClientParam.m_iAlarmHandle[i] != -1) // m_tree.SetItemImage(node1,1,1); // node1=m_tree.GetNextSiblingItem(node1); //} } void CSetAlarm::OnClickTreealarm(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here HTREEITEM node1; int imageindex,selectindex; node1=m_tree.GetSelectedItem(); if (node1==m_nSelItem) { *pResult = 0; return; } m_tree.GetItemImage(node1,imageindex,selectindex); if (imageindex==1) { m_tree.SetItemImage(node1,0,0); }else { m_tree.SetItemImage(node1,1,1); } *pResult = 0; } void CSetAlarm::OnDblclkTreealarm(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here HTREEITEM node1; int imageindex,selectindex; node1=m_tree.GetSelectedItem(); m_tree.GetItemImage(node1,imageindex,selectindex); if (imageindex==1) { m_tree.SetItemImage(node1,0,0); }else { m_tree.SetItemImage(node1,1,1); } *pResult = 0; } void CSetAlarm::OnSelchangedTreealarm(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; // TODO: Add your control notification handler code here HTREEITEM node1; int imageindex,selectindex; node1=m_tree.GetSelectedItem(); if (node1==m_nSelItem) { *pResult = 0; return; } m_tree.GetItemImage(node1,imageindex,selectindex); if (imageindex==1) { m_tree.SetItemImage(node1,0,0); }else { m_tree.SetItemImage(node1,1,1); } *pResult = 0; } void CSetAlarm::OnSelchangingTreealarm(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; // TODO: Add your control notification handler code here int imageindex,selectindex; m_nSelItem=m_tree.GetSelectedItem(); m_tree.GetItemImage(m_nSelItem,imageindex,selectindex); if (imageindex==1) { m_tree.SetItemImage(m_nSelItem,0,0); }else { m_tree.SetItemImage(m_nSelItem,1,1); } *pResult = 0; } void CSetAlarm::OnExit() { // TODO: Add your control notification handler code here CDialog::OnCancel(); } void CSetAlarm::OnCsetalarmok() { // TODO: Add your control notification handler code here //HTREEITEM node1; //int imageindex,selectindex; //int ipnum; //CString sTemp; //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber ); //CNewclientDlg *pDlg = g_pOCXCtrl[nIndex]->m_pDlgMain;//(CNewclientDlg *)this->GetParent(); // //node1=m_tree.GetRootItem(); //while(node1!=NULL) //{ // m_tree.GetItemImage(node1,imageindex,selectindex); // ipnum=m_tree.GetItemData(node1); // // if(imageindex==1) // { // if(pDlg->m_ClientParam.m_iAlarmHandle[ipnum] == -1) // { // pDlg->m_ClientParam.m_iAlarmHandle[ipnum] = NET_DVR_SetupAlarmChan(pDlg->m_Serverinfo[ipnum].m_lServerID); // if(pDlg->m_ClientParam.m_iAlarmHandle[ipnum] == -1) // { // m_tree.SetItemImage(node1,0,0); // sTemp.Format("%s报警设防失败 lasterror = %d!",pDlg->m_Serverinfo[ipnum].m_csServerName, NET_DVR_GetLastError()); // MessageBox(sTemp, "温馨提示", MB_ICONINFORMATION); // } // } // } // else // { // if(pDlg->m_ClientParam.m_iAlarmHandle[ipnum] >= 0) // { // if(NET_DVR_CloseAlarmChan(pDlg->m_ClientParam.m_iAlarmHandle[ipnum])) // { // pDlg->m_ClientParam.m_iAlarmHandle[ipnum] = -1; // } // else // { // m_tree.SetItemImage(node1,1,1); // sTemp.Format("%s报警撤防失败! lasterror = %d ",pDlg->m_Serverinfo[ipnum].m_csServerName, NET_DVR_GetLastError()); // MessageBox(sTemp, "温馨提示", MB_ICONINFORMATION); // } // } // } // node1=m_tree.GetNextSiblingItem(node1); //} //m_bOK = TRUE; // //MessageBox("布防撤防完成!", "温馨提示", MB_ICONINFORMATION); } void CSetAlarm::OnCancel() { // TODO: Add your control notification handler code here }