⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setitems.cpp

📁 一个opc服务器
💻 CPP
字号:
// SetItems.cpp : implementation file
//

#include "stdafx.h"
#include "mexOPC.h"
#include "SetItems.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString allitems[100];
CString readwriteallitems[100] ;

int zIndex;
int Count;
/////////////////////////////////////////////////////////////////////////////
// CSetItems dialog


CSetItems::CSetItems(CWnd* pParent /*=NULL*/)
	: CDialog(CSetItems::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetItems)
	//}}AFX_DATA_INIT
	nIndex =0;
	pIndex = 0;
	qIndex = 0;
	cIndex = 0;
	dIndex = 0;
}


void CSetItems::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetItems)
	DDX_Control(pDX, IDC_OPC_WRITEITEMS, m_writeitems);
	DDX_Control(pDX, IDC_OPC_READITEMS, m_readitems);
	DDX_Control(pDX, IDC_OPC_ALLITEMS, m_allitems);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetItems, CDialog)
	//{{AFX_MSG_MAP(CSetItems)
	ON_BN_CLICKED(IDC_OPC_ADDREADITEM, OnOpcAddreaditem)
	ON_BN_CLICKED(IDC_OPC_DELETEREADITEMS, OnOpcDeletereaditems)
	ON_BN_CLICKED(IDC_OPC_ADDWRITEITEMS, OnOpcAddwriteitems)
	ON_BN_CLICKED(IDC_OPC_DELETEWRITEITEMS, OnOpcDeletewriteitems)
	ON_LBN_SELCHANGE(IDC_OPC_ALLITEMS, OnSelchangeOpcAllitems)
	ON_BN_CLICKED(IDC_CANCEL, OnCancel)
	ON_LBN_SELCHANGE(IDC_OPC_READITEMS, OnSelchangeOpcReaditems)
	ON_LBN_SELCHANGE(IDC_OPC_WRITEITEMS, OnSelchangeOpcWriteitems)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetItems message handlers

void CSetItems::OnOpcAddreaditem() 
{
	// TODO: Add your control notification handler code here
	m_readitems.AddString(pCurrentItem);
    m_readallitems[cIndex] = pCurrentItem;
	cIndex++;
}

void CSetItems::OnOpcDeletereaditems() 
{
	// TODO: Add your control notification handler code here
	m_readitems.DeleteString(pIndex);
}

void CSetItems::OnOpcAddwriteitems() 
{
	// TODO: Add your control notification handler code here
	m_writeitems.AddString(pCurrentItem);
	m_writeallitems[dIndex] = pCurrentItem;
	dIndex++;
}

void CSetItems::OnOpcDeletewriteitems() 
{
	// TODO: Add your control notification handler code here
	m_writeitems.DeleteString(qIndex);
}

void CSetItems::OnCancel() 
{
	// TODO: Add your control notification handler code here
	for(int i =0;i<cIndex;i++)
		readwriteallitems[i] = m_readallitems[i];
	zIndex = cIndex;
	for(i=0;i<dIndex;i++)
        readwriteallitems[i] = m_writeallitems[i];
	Count = cIndex + dIndex;
	CDialog::OnCancel();
}

void CSetItems::OnSelchangeOpcAllitems() 
{
	// TODO: Add your control notification handler code here
	nIndex = m_allitems.GetCurSel();
	pCurrentItem = allitems[nIndex];
}

BOOL CSetItems::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	for(nIndex=0;nIndex<Itemcount;nIndex++)
	m_allitems.AddString(allitems[nIndex]);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSetItems::OnSelchangeOpcReaditems() 
{
	// TODO: Add your control notification handler code here
	pIndex = m_readitems.GetCurSel();
}

void CSetItems::OnSelchangeOpcWriteitems() 
{
	// TODO: Add your control notification handler code here
	qIndex = m_writeitems.GetCurSel();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -