MFC工控项目实例二十九主对话框调用子对话框设定参数值

在主对话框调用子对话框设定参数值,使用theApp变量实现。

子对话框各参数变量

CString m_strTypeName; CString m_strBrand; CString m_strRemark;

double m_edit_min; double m_edit_max;

double m_edit_time2;

double m_edit_time1;

double m_edit_time3;

DWORD m_edit_time4;

参考MFC工控项目实例二十七添加产品参数

1、在SEAL_PRESSURE.h中添加代码

cpp 复制代码
class CProductPara
{
public:
	union
	{
		struct
		{
			char	m_strTypeName[24];
			char	m_strBrand[24];			
			char	m_strRemark[64];
			double	m_edit_min;
            double	m_edit_max;
            double	m_edit_time1;
			double	m_edit_time2;
		    double	m_edit_time3;
			double	m_edit_time4;
		};
		char len[1024];
	};
};


class CSEAL_PRESSUREApp : public CWinApp
{
public:
	CSEAL_PRESSUREApp();
              
			CString   m_strTypeName;
            CString   m_strBrand;	
            CString   m_strRemark;
			double	m_edit_min;
            double	m_edit_max;
            double	m_edit_time1;
			double	m_edit_time2;
		    double	m_edit_time3;
			double	m_edit_time4;
...
}

2、在SEAL_PRESSURE.h中添加代码

cpp 复制代码
void CSEAL_PRESSUREDlg::OnTypeChange(UINT nID)
{
	theApp.m_nProductSel = nID - ID_DEF_PRODUCT+1;
	CWinApp* pApp = AfxGetApp();
    int i=pApp->WriteProfileInt("参数","nProductSel1",theApp.m_nProductSel);
    CString str = theApp.m_allPara[theApp.m_nProductSel].m_strTypeName;
    theApp.typ_name=theApp.m_DataPath+"\\"+str+"\\";
	 CreateDirectory(theApp.typ_name,FALSE);
	  
    theApp.m_strTypeName= theApp.m_allPara[theApp.m_nProductSel].m_strTypeName;
	theApp.m_strBrand= theApp.m_allPara[theApp.m_nProductSel].m_strBrand;
	theApp.m_strRemark= theApp.m_allPara[theApp.m_nProductSel].m_strRemark;
	theApp.m_edit_min= theApp.m_allPara[theApp.m_nProductSel].m_edit_min;
	theApp.m_edit_max= theApp.m_allPara[theApp.m_nProductSel].m_edit_max;
    theApp.m_edit_time1= theApp.m_allPara[theApp.m_nProductSel].m_edit_time1;
	theApp.m_edit_time2= theApp.m_allPara[theApp.m_nProductSel].m_edit_time2;
    theApp.m_edit_time1= theApp.m_allPara[theApp.m_nProductSel].m_edit_time1;
	theApp.m_edit_time2= theApp.m_allPara[theApp.m_nProductSel].m_edit_time2;
	theApp.m_edit_time3= theApp.m_allPara[theApp.m_nProductSel].m_edit_time3;
	theApp.m_edit_time4= theApp.m_allPara[theApp.m_nProductSel].m_edit_time4;
	SetDlgItemText(IDC_STATIC_TYPNAME,theApp.m_strTypeName);
   CString str1,str2;
	str1.Format("%3.2f",theApp.m_edit_min);
	str2.Format("%3.2f",theApp.m_edit_max);
	SetDlgItemText(IDC_STATIC100,str1);
	SetDlgItemText(IDC_STATIC102,str2);
	if (i!=0)
	{
	   m_TES_START.EnableWindow (1);
	}
    
}

运行程序

相关推荐
tan180°3 小时前
MySQL表的操作(3)
linux·数据库·c++·vscode·后端·mysql
彭祥.5 小时前
Jetson边缘计算主板:Ubuntu 环境配置 CUDA 与 cudNN 推理环境 + OpenCV 与 C++ 进行目标分类
c++·opencv·分类
lzb_kkk5 小时前
【C++】C++四种类型转换操作符详解
开发语言·c++·windows·1024程序员节
胖大和尚7 小时前
clang 编译器怎么查看在编译过程中做了哪些优化
c++·clang
钱彬 (Qian Bin)8 小时前
一文掌握Qt Quick数字图像处理项目开发(基于Qt 6.9 C++和QML,代码开源)
c++·开源·qml·qt quick·qt6.9·数字图像处理项目·美观界面
双叶8369 小时前
(C++)学生管理系统(正式版)(map数组的应用)(string应用)(引用)(文件储存的应用)(C++教学)(C++项目)
c语言·开发语言·数据结构·c++
源代码•宸9 小时前
C++高频知识点(二)
开发语言·c++·经验分享
jyan_敬言10 小时前
【C++】string类(二)相关接口介绍及其使用
android·开发语言·c++·青少年编程·visual studio
liulilittle11 小时前
SNIProxy 轻量级匿名CDN代理架构与实现
开发语言·网络·c++·网关·架构·cdn·通信
tan77º11 小时前
【Linux网络编程】Socket - UDP
linux·服务器·网络·c++·udp