📄 dectectset.cpp
字号:
// DectectSet.cpp : implementation file
//
#include "stdafx.h"
#include "moinorcentre.h"
#include "DectectSet.h"
#include "MoinorCentreDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDectectSet dialog
CDectectSet::CDectectSet(CWnd* pParent /*=NULL*/)
: CDialog(CDectectSet::IDD, pParent)
{
//{{AFX_DATA_INIT(CDectectSet)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDectectSet::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDectectSet)
DDX_Control(pDX, IDC_LIST2, m_list2);
DDX_Control(pDX, IDC_LIST1, m_list1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDectectSet, CDialog)
//{{AFX_MSG_MAP(CDectectSet)
ON_BN_CLICKED(IDC_BEIJING, OnBeijing)
ON_BN_CLICKED(IDC_BAOJINGOK, OnBaojingok)
ON_BN_CLICKED(IDC_STOP, OnStop)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_BN_CLICKED(IDC_JIANCEOK, OnJianceok)
ON_BN_CLICKED(IDC_OBJECTSTOP, OnObjectstop)
ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeList2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDectectSet message handlers
BOOL CDectectSet::OnInitDialog()
{
CDialog::OnInitDialog();
alarmlevel=2;
db.Open("port.mdb");
CDaoTableDef tb(&db);
tb.Open("site");
CSiteRecord rs;
rs.Open(&tb,dbOpenDynaset);
while(!rs.IsEOF())
{ CString state1="关闭";
CString state2="关闭";
CMoinorCentreApp* pwnd=(CMoinorCentreApp*)(AfxGetApp());
if( pwnd->alarmst[rs.m_SiteID].onoff)
{if(pwnd->alarmst[rs.m_SiteID].alramtype==0)
state1="打开";
else
state2="打开";
}
CString id1;
id1.Format("ID为%d,%s,图像表名%s 报警状态%s",rs.m_SiteID,rs.m_SiteName,rs.m_SiteTable,state1);
CString id2;
id2.Format("ID为%d,%s,图像表名%s 图像识别状态%s",rs.m_SiteID,rs.m_SiteName,rs.m_SiteTable,state2);
m_list1.AddString(id1);
m_list2.AddString(id2);
rs.MoveNext();
}
rs.Close();
tb.Close();
// TODO: Add extra initialization here
GetDlgItem(IDC_BAOJINGOK)->EnableWindow(FALSE);
GetDlgItem(IDC_STOP)->EnableWindow(FALSE);
GetDlgItem(IDC_JIANCEOK)->EnableWindow(FALSE);
GetDlgItem(IDC_OBJECTSTOP)->EnableWindow(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDectectSet::OnBeijing()
{
CDaoTableDef picsite(&db);
CString str;
int i=m_list2.GetCurSel();
m_list2.GetText(i,str);
int j=str.FindOneOf("名");
CString m_sitetablename=str.Mid(j+2);
//AfxMessageBox(m_sitetablename);
picsite.Open(m_sitetablename);
piclist.picrs.Open(&picsite,dbOpenDynaset);
picsite.Close();
piclist.Create(IDD_PICLIST,this);// TODO: Add your control notification handler code here
piclist.ShowWindow(SW_SHOW);
piclist.objectid=objectid;
//AfxMessageBox("请点击一副图像作为初始背景");
}
void CDectectSet::OnBaojingok()
{
CString str;
int i=m_list1.GetCurSel(); // TODO: Add your control notification handler code here
m_list1.GetText(i,str);
int j=str.FindOneOf("为");
char ids=str[j+2];
int id=atoi(&ids);
CMoinorCentreApp* pwnd=((CMoinorCentreApp*)AfxGetApp());
pwnd->alarmst[id].alramtype=0;
pwnd->alarmst[id].onoff=TRUE;
pwnd->alarmst[id].alarmlevel=alarmlevel;
str.Replace("关闭","打开");
m_list1.DeleteString(i);
m_list1.InsertString(i,str);
GetDlgItem(IDC_BAOJINGOK)->EnableWindow(FALSE);
}
void CDectectSet::OnStop()
{
CString str;
int i=m_list1.GetCurSel(); // TODO: Add your control notification handler code here
m_list1.GetText(i,str);
int j=str.FindOneOf("为");
char ids=str[j+2];
int id=atoi(&ids);
CMoinorCentreApp* pwnd=((CMoinorCentreApp*)AfxGetApp());
if(pwnd->alarmst[id].alramtype==0)
pwnd->alarmst[id].onoff=FALSE;
str.Replace("打开","关闭");
m_list1.DeleteString(i);
m_list1.InsertString(i,str);
GetDlgItem(IDC_STOP)->EnableWindow(FALSE);
}
void CDectectSet::OnRadio1()
{
alarmlevel=1;// TODO: Add your control notification handler code here
}
void CDectectSet::OnRadio2()
{
alarmlevel=2;
}
void CDectectSet::OnRadio3()
{
alarmlevel=3;
}
void CDectectSet::OnJianceok()
{
CString str;
int i=m_list2.GetCurSel(); // TODO: Add your control notification handler code here
m_list2.GetText(i,str);
int j=str.FindOneOf("为");
char ids=str[j+2];
int id=atoi(&ids);
objectid=id;
//CMoinorCentreApp* pwnd=((CMoinorCentreApp*)AfxGetApp());
//pwnd->alarmst[id].alramtype=1;
//pwnd->alarmst[id].onoff=TRUE;
CDaoTableDef picsite(&db);
CString str1;
i=m_list2.GetCurSel();
m_list2.GetText(i,str1);
j=str1.FindOneOf("名");
CString m_sitetablename=str1.Mid(j+2,5);
//AfxMessageBox(m_sitetablename);
picsite.Open(m_sitetablename);
piclist.picrs.Open(&picsite,dbOpenDynaset);
picsite.Close();
piclist.Create(IDD_PICLIST,this);// TODO: Add your control notification handler code here
piclist.ShowWindow(SW_SHOW);
piclist.objectid=objectid;
str.Replace("关闭","打开");
m_list2.DeleteString(i);
m_list2.InsertString(i,str);
GetDlgItem(IDC_JIANCEOK)->EnableWindow(FALSE);
}
void CDectectSet::OnObjectstop()
{
CString str;
int i=m_list2.GetCurSel(); // TODO: Add your control notification handler code here
m_list2.GetText(i,str);
int j=str.FindOneOf("为");
char ids=str[j+2];
int id=atoi(&ids);
CMoinorCentreApp* pwnd=((CMoinorCentreApp*)AfxGetApp());
if(pwnd->alarmst[id].alramtype==1)
pwnd->alarmst[id].onoff=FALSE;
str.Replace("打开","关闭");
m_list2.DeleteString(i);
m_list2.InsertString(i,str);
GetDlgItem(IDC_OBJECTSTOP)->EnableWindow(FALSE);
}
void CDectectSet::OnSelchangeList1()
{
CString str;
int i=m_list1.GetCurSel(); // TODO: Add your control notification handler code here
m_list1.GetText(i,str); // TODO: Add your control notification handler code here
if(str.Find("关闭")==-1)
{GetDlgItem(IDC_BAOJINGOK)->EnableWindow(FALSE);
GetDlgItem(IDC_STOP)->EnableWindow(TRUE);
}
else
{GetDlgItem(IDC_BAOJINGOK)->EnableWindow(TRUE);
GetDlgItem(IDC_STOP)->EnableWindow(FALSE);
}
}
void CDectectSet::OnSelchangeList2()
{
CString str;
int i=m_list2.GetCurSel(); // TODO: Add your control notification handler code here
m_list2.GetText(i,str); // TODO: Add your control notification handler code here
if(str.Find("关闭")==-1)
{GetDlgItem(IDC_JIANCEOK)->EnableWindow(FALSE);
GetDlgItem(IDC_OBJECTSTOP)->EnableWindow(TRUE);
}
else
{GetDlgItem(IDC_JIANCEOK)->EnableWindow(TRUE);
GetDlgItem(IDC_OBJECTSTOP)->EnableWindow(FALSE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -