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

运行程序

相关推荐
~山有木兮几秒前
C++设计模式 - 单例模式
c++·单例模式·设计模式
十五年专注C++开发12 分钟前
CMake基础:gcc/g++编译选项详解
开发语言·c++·gcc·g++
HUN金克斯1 小时前
C++/C函数
c语言·开发语言·c++
慢半拍iii1 小时前
数据结构——F/图
c语言·开发语言·数据结构·c++
iceslime1 小时前
旅行商问题(TSP)的 C++ 动态规划解法教学攻略
数据结构·c++·算法·算法设计与分析
虾球xz2 小时前
CppCon 2015 学习:3D Face Tracking and Reconstruction using Modern C++
开发语言·c++·学习·3d
small_wh1te_coder3 小时前
c语言超详细知识点总结 1500行手写源码 持续更新中ing 从25年5月到6月5日
c++·c
SteveDraw4 小时前
C++动态链接库封装,供C#/C++ 等编程语言使用——C++动态链接库概述(总)
开发语言·c++·c#·封装·动态链接库
十五年专注C++开发4 小时前
设计模式之单例模式(二): 心得体会
开发语言·c++·单例模式·设计模式
?!7145 小时前
算法打卡第18天
c++·算法