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);
	}
    
}

运行程序

相关推荐
寒笙LED30 分钟前
C++详细笔记(六)string库
开发语言·c++·笔记
就爱六点起2 小时前
C/C++ 中的类型转换方式
c语言·开发语言·c++
召木3 小时前
C++小白实习日记——Day 2 TSCNS怎么读取当前时间
c++·职场和发展
St_Ludwig3 小时前
C语言 蓝桥杯某例题解决方案(查找完数)
c语言·c++·后端·算法·游戏·蓝桥杯
Jack黄从零学c++4 小时前
opencv(c++)---自带的卷积运算filter2D以及应用
c++·人工智能·opencv
sweetheart7-74 小时前
LeetCode20. 有效的括号(2024冬季每日一题 11)
c++·算法·力扣··括号匹配
gma9994 小时前
brpc 与 Etcd 二次封装
数据库·c++·rpc·etcd
ö Constancy4 小时前
设计LRU缓存
c++·算法·缓存
C++忠实粉丝5 小时前
计算机网络socket编程(2)_UDP网络编程实现网络字典
linux·网络·c++·网络协议·计算机网络·udp
Mongxin_Chan5 小时前
【Cpp】指针与引用
c++·算法