MFC工控项目实例三十二模拟量校正值添加修改删除

用两个列表控件实现三十二模拟量校正值添加、修改、删除。

相关代码

cpp 复制代码
void SenSet::OnSelchangeList1() //修改
{
	m_bAdd_2.EnableWindow(true);
	m_bParameter_2.EnableWindow(true);
	m_bDel_2.EnableWindow(false);
	nSel =m_IDC_LIST1.GetCurSel();
    m_IDC_LIST1.GetText(nSel,nSel_str);
	CString str;
	str.Format("%d",nSel);
	
	CString str6[16],str7[16],str8[16],str9[16];

	GetPrivateProfileString("A/D设置",nSel_str+"零点电压",NULL,str6[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"零点数值",NULL,str7[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"量程电压",NULL,str8[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"量程数值",NULL,str9[16].GetBuffer(20),20,theApp.strFilePath);
    m_IDC_LIST2.DeleteAllItems();
	m_IDC_LIST2.InsertItem(0, _T("1"));   
    m_IDC_LIST2.SetItemText(0, 1,_T(str6[16]));  
    SetDlgItemText(IDC_EDIT1,_T(str6[16]));
    m_IDC_LIST2.SetItemText(0, 2,str7[16]);
	SetDlgItemText(IDC_EDIT2,_T(str7[16]));
    m_IDC_LIST2.InsertItem(1, _T("2"));   
    m_IDC_LIST2.SetItemText(1, 1,str8[16]);
	SetDlgItemText(IDC_EDIT4,_T(str8[16]));
    m_IDC_LIST2.SetItemText(1, 2,str9[16]);
    SetDlgItemText(IDC_EDIT5,_T(str9[16]));
	if (str6[16]!="" && str7[16]!="" && str8[16]!="" && str9[16]!="")
	{
    SetDlgItemText(IDC_BUTTON1,"修改");
	}
	else 
	{
		SetDlgItemText(IDC_BUTTON1,"添加");
	}
}



void SenSet::OnButton1() //添加
{
	
	CString str1,str2,str4,str5;
	CString str6[16],str7[16],str8[16],str9[16];
	GetDlgItemText(IDC_EDIT1,str1);
	GetDlgItemText(IDC_EDIT2,str2);
	GetDlgItemText(IDC_EDIT4,str4);
	GetDlgItemText(IDC_EDIT5,str5);
    WritePrivateProfileString("A/D设置",nSel_str+"零点电压",str1,theApp.strFilePath);
    WritePrivateProfileString("A/D设置",nSel_str+"零点数值",str2,theApp.strFilePath);
    WritePrivateProfileString("A/D设置",nSel_str+"量程电压",str4,theApp.strFilePath);
    WritePrivateProfileString("A/D设置",nSel_str+"量程数值",str5,theApp.strFilePath);
	
	GetPrivateProfileString("A/D设置",nSel_str+"零点电压",NULL,str6[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"零点数值",NULL,str7[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"量程电压",NULL,str8[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"量程数值",NULL,str9[16].GetBuffer(20),20,theApp.strFilePath);
    m_IDC_LIST2.DeleteAllItems();
    m_IDC_LIST2.InsertItem(0, _T("1"));   
    m_IDC_LIST2.SetItemText(0, 1,_T(str6[16]));  
    m_IDC_LIST2.SetItemText(0, 2,str7[16]); 
//	m_IDC_LIST2.DeleteAllItems();
    m_IDC_LIST2.InsertItem(1, _T("2"));   
    m_IDC_LIST2.SetItemText(1, 1,str8[16]);  
    m_IDC_LIST2.SetItemText(1, 2,str9[16]);  

	for(int i=0;i<theApp.COMB_Data_AD_Number_1;i++)
   {
	   
	 GetPrivateProfileString("AD输入",theApp.COMB_Data_AD_1[i],NULL,theApp.b_str_AD_1[i].GetBuffer(20),20,theApp.strFilePath);	
     theApp.AD_1[i]=_ttoi(theApp.b_str_AD_1[i]);
	 if (theApp.b_str_AD_1[i]!="-1" )
	 {

	GetPrivateProfileString("A/D设置",theApp.COMB_Data_AD_1[i]+"零点电压",NULL,theApp.AD_SET_ZERO_VLO[theApp.AD_1[i]].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",theApp.COMB_Data_AD_1[i]+"零点数值",NULL,theApp.AD_SET_ZERO_NUM[theApp.AD_1[i]].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",theApp.COMB_Data_AD_1[i]+"量程电压",NULL,theApp.AD_SET_RAN_VLO[theApp.AD_1[i]].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",theApp.COMB_Data_AD_1[i]+"量程数值",NULL,theApp.AD_SET_RAN_NUM[theApp.AD_1[i]].GetBuffer(20),20,theApp.strFilePath);
//	SetDlgItemText(IDC_STATIC99,theApp.AD_SET_RAN_NUM[theApp.AD_1[15]]);

   theApp.flo_AD_SET_ZERO_VLO[i]= (float)atof(theApp.AD_SET_ZERO_VLO[theApp.AD_1[i]]);
   theApp.flo_AD_SET_ZERO_NUM[i]= (float)atof(theApp.AD_SET_ZERO_NUM[theApp.AD_1[i]]);
   theApp.flo_AD_SET_RAN_VLO[i]= (float)atof(theApp.AD_SET_RAN_VLO[theApp.AD_1[i]]);
   theApp.flo_AD_SET_RAN_NUM[i]= (float)atof(theApp.AD_SET_RAN_VLO[theApp.AD_1[i]]);
	 }
	}
}



void SenSet::OnButton2() //删除
{
	  int nIndex = m_IDC_LIST2.GetSelectionMark();
	  CString str;
	  str.Format("%d",nIndex);
       if (nIndex==0)
	  {
     WritePrivateProfileString("A/D设置",nSel_str+"零点电压",NULL,theApp.strFilePath);
     WritePrivateProfileString("A/D设置",nSel_str+"零点数值",NULL,theApp.strFilePath);
	// SetDlgItemText(IDC_STATIC99,"1");  
	  }
	  if (nIndex==1)
	  {
     WritePrivateProfileString("A/D设置",nSel_str+"量程电压","",theApp.strFilePath);
     WritePrivateProfileString("A/D设置",nSel_str+"量程数值","",theApp.strFilePath);
	  }
	  	CString str6[16],str7[16],str8[16],str9[16];
    GetPrivateProfileString("A/D设置",nSel_str+"零点电压",NULL,str6[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"零点数值",NULL,str7[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"量程电压",NULL,str8[16].GetBuffer(20),20,theApp.strFilePath);
	GetPrivateProfileString("A/D设置",nSel_str+"量程数值",NULL,str9[16].GetBuffer(20),20,theApp.strFilePath);
    m_IDC_LIST2.DeleteAllItems();
	m_IDC_LIST2.InsertItem(0, _T("1"));   
    m_IDC_LIST2.SetItemText(0, 1,_T(str6[16]));  
    SetDlgItemText(IDC_EDIT1,_T(str6[16]));
    m_IDC_LIST2.SetItemText(0, 2,str7[16]);
	SetDlgItemText(IDC_EDIT2,_T(str7[16]));
    m_IDC_LIST2.InsertItem(1, _T("2"));   
    m_IDC_LIST2.SetItemText(1, 1,str8[16]);
	SetDlgItemText(IDC_EDIT4,_T(str8[16]));
    m_IDC_LIST2.SetItemText(1, 2,str9[16]);
    SetDlgItemText(IDC_EDIT5,_T(str9[16]));	  
}
相关推荐
胖大和尚42 分钟前
clang 编译器怎么查看在编译过程中做了哪些优化
c++·clang
钱彬 (Qian Bin)2 小时前
一文掌握Qt Quick数字图像处理项目开发(基于Qt 6.9 C++和QML,代码开源)
c++·开源·qml·qt quick·qt6.9·数字图像处理项目·美观界面
双叶8362 小时前
(C++)学生管理系统(正式版)(map数组的应用)(string应用)(引用)(文件储存的应用)(C++教学)(C++项目)
c语言·开发语言·数据结构·c++
源代码•宸3 小时前
C++高频知识点(二)
开发语言·c++·经验分享
jyan_敬言4 小时前
【C++】string类(二)相关接口介绍及其使用
android·开发语言·c++·青少年编程·visual studio
liulilittle4 小时前
SNIProxy 轻量级匿名CDN代理架构与实现
开发语言·网络·c++·网关·架构·cdn·通信
tan77º5 小时前
【Linux网络编程】Socket - UDP
linux·服务器·网络·c++·udp
GiraKoo6 小时前
【GiraKoo】C++14的新特性
c++
悠悠小茉莉6 小时前
Win11 安装 Visual Studio(保姆教程 - 更新至2025.07)
c++·ide·vscode·python·visualstudio·visual studio
坏柠6 小时前
C++ Qt 基础教程:信号与槽机制详解及 QPushButton 实战
c++·qt