MFC工控项目实例之十三从文件读写板卡信号名称

承接专栏《MFC工控项目实例之十二板卡测试信号输出界面》

1、在BoardTest.h文件中添加代码

cpp 复制代码
class CBoardTest : public CDialog
{

public:
	CBoardTest(CWnd* pParent = NULL);   // standard constructor
	...
CString NO_Combox[16];
CString strTemp[16];//数据项名称
CString strRead[16];
int strReadId[16];
char strBuff[256];
CString	m_Path;
CString strFilePath;
...
}

2、在BoardTest.cpp文件中添加代码

cpp 复制代码
CBoardTest::CBoardTest(CWnd* pParent /*=NULL*/)
	: CDialog(CBoardTest::IDD, pParent)
{
TCHAR exeFullPath[MAX_PATH];
	GetModuleFileName(NULL,exeFullPath,MAX_PATH);
	m_Path = exeFullPath;
	for(int i = m_Path.GetLength() - 1; i > 0 ; i --)
	{
		if(m_Path.GetAt(i) == '\\')
			break;
	}
	SetCurrentDirectory(m_Path);
	m_Path = m_Path.Left(i);
    strFilePath= m_Path + "\\Test.ini";
	
}


BOOL CBoardTest::OnInitDialog() 
{
		CDialog::OnInitDialog();
	...
	for (int m=0; m<16; m++)
	{	 
		   	
		 GetPrivateProfileString("输入信号",COMB_Data[m+1],NULL,strRead[m].GetBuffer(20),20,strFilePath);	
          strReadId[m]=_ttoi(strRead[m]);
		  if(strReadId[m]!=-1)
		  {
         ((CComboBox*)GetDlgItem(m_CountComboID[strReadId[m]]))->SetWindowText(COMB_Data[m+1]);
		  }
	}


  for ( m=0; m<16; m++)
	{	 
		   	
		 GetPrivateProfileString("输出信号",COMB_Data_O[m+1],NULL,strRead[m].GetBuffer(20),20,strFilePath);	
          strReadId[m]=_ttoi(strRead[m]);
		  if(strReadId[m]!=-1)
		  {
         ((CComboBox*)GetDlgItem(m_CountComboID_O[strReadId[m]]))->SetWindowText(COMB_Data_O[m+1]);
		  }
	}
	
	return TRUE; 
	}


void CBoardTest::OnButton3() 
{
for (int m=1; m<17; m++)
	{					 
		       	
		  WritePrivateProfileString("输入信号",COMB_Data[m],"-1",strFilePath);
			
	} 
	for (int n=0; n<16; n++)
	{
						 
		 ((CComboBox*)GetDlgItem(m_CountComboID[n]))->GetWindowText(strTemp[n]);//当前内容
		 NO_Combox[n].Format(_T("%d"), n);   	 
		 if (strTemp[n]!="------")
		 {
		  WritePrivateProfileString("输入信号",strTemp[n],NO_Combox[n],strFilePath);
		 }			
	} 


for ( m=1; m<17; m++)
	{					 
		       	
		  WritePrivateProfileString("输出信号",COMB_Data_O[m],"-1",strFilePath);
			
	} 
	for ( n=0; n<16; n++)
	{
						 
		 ((CComboBox*)GetDlgItem(m_CountComboID_O[n]))->GetWindowText(strTemp[n]);//当前内容
		 NO_Combox[n].Format(_T("%d"), n);   	 
		 if (strTemp[n]!="------")
		 {
		  WritePrivateProfileString("输出信号",strTemp[n],NO_Combox[n],strFilePath);
		 }			
	} 

	 Sleep(500);
EndDialog(IDD_DIALOG_BOA_TEST);
}

运行程序

相关推荐
端平入洛1 天前
delete又未完全delete
c++
端平入洛2 天前
auto有时不auto
c++
哇哈哈20213 天前
信号量和信号
linux·c++
多恩Stone3 天前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
蜡笔小马3 天前
21.Boost.Geometry disjoint、distance、envelope、equals、expand和for_each算法接口详解
c++·算法·boost
超级大福宝3 天前
N皇后问题:经典回溯算法的一些分析
数据结构·c++·算法·leetcode
weiabc3 天前
printf(“%lf“, ys) 和 cout << ys 输出的浮点数格式存在细微差异
数据结构·c++·算法
问好眼3 天前
《算法竞赛进阶指南》0x01 位运算-3.64位整数乘法
c++·算法·位运算·信息学奥赛
yyjtx3 天前
DHU上机打卡D31
开发语言·c++·算法
czxyvX3 天前
020-C++之unordered容器
数据结构·c++