⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mdsetpar.cpp

📁 《面向对象程序设计实用教程》一书的源码
💻 CPP
字号:
// mdsetpar.cpp : implementation file
//

#include "stdafx.h"
#include "cge.h"
#include "mdsetpar.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// mdsetpar dialog


mdsetpar::mdsetpar(CWnd* pParent /*=NULL*/)
	: CDialog(mdsetpar::IDD, pParent)
{
	//{{AFX_DATA_INIT(mdsetpar)
	m_mdpath = _T("");
	m_mdfile = _T("");
	m_hour = _T("");
	m_dingshi = _T("");
	m_minute = _T("");
	//}}AFX_DATA_INIT
}


void mdsetpar::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(mdsetpar)
	DDX_Control(pDX, IDC_COMBOtongdao, m_tongdao);
	DDX_Control(pDX, IDC_COMBOjiange, m_jiange);
	DDX_Control(pDX, IDC_COMBOgaojie, m_gaojie);
	DDX_Control(pDX, IDC_COMBOdijie, m_dijie);
	DDX_Control(pDX, IDC_COMBOchangdu, m_changdu);
	DDX_Text(pDX, IDC_EDIT2, m_mdpath);
	DDX_Text(pDX, IDC_EDIT5, m_mdfile);
	DDX_Text(pDX, IDC_EDIT1, m_hour);
	DDX_Text(pDX, IDC_EDIT4, m_dingshi);
	DDX_Text(pDX, IDC_EDIT3, m_minute);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(mdsetpar, CDialog)
	//{{AFX_MSG_MAP(mdsetpar)
	ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
	ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
	ON_EN_KILLFOCUS(IDC_EDIT3, OnKillfocusEdit3)
	ON_EN_KILLFOCUS(IDC_EDIT4, OnKillfocusEdit4)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// mdsetpar message handlers

BOOL mdsetpar::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CheckRadioButton(IDC_RADIO11,IDC_RADIO22,IDC_RADIO22);	

	if(s[5]=="开")
	{
		CheckRadioButton(IDC_RADIO11,IDC_RADIO22,IDC_RADIO11);
	}else
	{
		CheckRadioButton(IDC_RADIO11,IDC_RADIO22,IDC_RADIO22);
	}
	//m_cf.SelectString(-1,s[7]);
	
//	UpdateData(false);
	
	m_tongdao.SelectString(-1,s[0]);
    m_gaojie.SelectString(-1,s[1]);
	m_dijie.SelectString(-1,s[2]);
	m_changdu.SelectString(-1,s[5]);
	m_jiange.SelectString(-1,s[4]);
	
	m_hour = s[9];
	m_minute = " ";
	m_dingshi = s[10];
	m_mdpath = s[11];
	m_mdfile = s[12];
	m_minute = s[13];
	UpdateData(false);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void mdsetpar::OnRadio4() 
{
	GetDlgItem(IDC_BUTTONshoudong)->EnableWindow(true);
	GetDlgItem(IDOK)->EnableWindow(false);	
}

void mdsetpar::OnRadio5() 
{
	GetDlgItem(IDOK)->EnableWindow(true);
	GetDlgItem(IDC_BUTTONshoudong)->EnableWindow(false);
	
}

void mdsetpar::OnOK() 
{
    //int m_cfRadio;
	int m_xianboRadio;
	m_tongdao.GetWindowText(s[0]); //具体通道
	m_gaojie.GetWindowText(s[1]);
	m_dijie.GetWindowText(s[2]);
	
	m_xianboRadio = GetCheckedRadioButton(IDC_RADIO11,IDC_RADIO22);
	if(m_xianboRadio == IDC_RADIO11)
	{
		s[3] = "开";
	}else
	{
		s[3] = "关";
	}
	m_jiange.GetWindowText(s[4]);
	m_changdu.GetWindowText(s[5]);
	//m_ys.GetWindowText(s[6]);
	s[6] = "0.000";//延时
	
	
	//m_TDNo.GetWindowText(s[8]);  //通道数
	s[7] =  "内";
	s[8] = "6";    
	
	//将参数发送到COM口
	channel_index = 1;//m_TDNo.GetCurSel();//通道数 = 6
	tongdao_index = m_tongdao.GetCurSel(); //具体
	jiange_index  = m_jiange.GetCurSel();
	length_index  = m_changdu.GetCurSel();
	gaojie_index  = m_gaojie.GetCurSel();
	dijie_index   = m_dijie.GetCurSel();


	chufa_index = 1; //内触发
	
	//xianbo_index  = m_xianbo.GetCurSel();
	if(s[3] == "开" )
	{
		xianbo_index = 0;
	}else
	{
		xianbo_index = 1;
	}
	
	CDialog::OnOK();
}



void mdsetpar::OnKillfocusEdit3() 
{
	// TODO: Add your control notification handler code here
	
	UpdateData(true);
	
	if(atoi(m_minute) > 59 || atoi(m_minute) < 0 ) 
	{
		MessageBox(" <= 56 分 AND >= 0 分! ");	
		GetDlgItem(IDC_EDIT3)->SetFocus();
		m_minute = "";  
		
	}
		
	UpdateData(false);
	
}

void mdsetpar::OnKillfocusEdit4() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	int maxminute = atoi(m_hour)*60 + atoi(m_minute);	
	CString maxminutes;
	maxminutes.Format("%d", maxminute); 
	if(atoi(m_dingshi) > maxminute || atoi(m_dingshi) < 0 ) 
	{
		MessageBox(" <= " + maxminutes + " 分 AND >= 0 分! ");	
		GetDlgItem(IDC_EDIT4)->SetFocus();
		m_dingshi = "";  
		
	}
		
	UpdateData(false);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -