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

运行程序

相关推荐
别NULL7 分钟前
机试题——最小矩阵宽度
c++·算法·矩阵
Icomi_1 小时前
【外文原版书阅读】《机器学习前置知识》1.线性代数的重要性,初识向量以及向量加法
c语言·c++·人工智能·深度学习·神经网络·机器学习·计算机视觉
apocelipes1 小时前
Linux glibc自带哈希表的用例及性能测试
c语言·c++·哈希表·linux编程
Ronin-Lotus2 小时前
上位机知识篇---CMake
c语言·c++·笔记·学习·跨平台·编译·cmake
wyg_0311132 小时前
C++资料
开发语言·c++
A charmer3 小时前
算法每日双题精讲 —— 二分查找(山脉数组的峰顶索引,寻找峰值)
c++·算法
Zfox_3 小时前
HTTP cookie 与 session
linux·服务器·网络·c++·网络协议·http
软工在逃男大学生3 小时前
转换算术表达式
c语言·数据结构·c++·算法
我爱_编程3 小时前
MFC常用操作
mfc
小黄人软件4 小时前
【MFC】C++所有控件随窗口大小全自动等比例缩放源码(控件内字体、列宽等未调整) 20250124
开发语言·c++·ui·mfc