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

📄 setpar.cpp

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

#include "stdafx.h"
#include "cge.h"
#include "Setpar.h"
#include "softkeydlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// Setpar dialog


Setpar::Setpar(CWnd* pParent /*=NULL*/)
	: CDialog(Setpar::IDD, pParent)
{
	
	 channel_index=0;
	 power_index=0;
	 xianbo_index=0;
	 dijie_index=0;
	 gaojie_index=0;
	 jiange_index=0;
	 length_index=0;
	 zengyi_index=0;
	 chufa_index=0;
	 yanshi_time=0;
	 tongdao_index=0;
	
	//{{AFX_DATA_INIT(Setpar)
	//}}AFX_DATA_INIT


}


void Setpar::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Setpar)
	DDX_Control(pDX, IDC_BUTTON1, m_butoon1);
	DDX_Control(pDX, IDC_COMBO5, m_caiyjg);
	DDX_Control(pDX, IDC_COMBO7, m_TDNo); //选择通道数
	DDX_Control(pDX, IDC_EDIT1, m_ys);
	DDX_Control(pDX, IDC_SPIN2, m_spin);
	DDX_Control(pDX, IDC_COMBO6, m_caiycd);
	DDX_Control(pDX, IDC_COMBO3, m_dijie);
	DDX_Control(pDX, IDC_COMBO1, m_gaojie);
	DDX_Control(pDX, IDC_COMBO2, m_tongdao); //选择具体通道
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Setpar, CDialog)
	//{{AFX_MSG_MAP(Setpar)
	ON_CBN_DROPDOWN(IDC_COMBO2, OnDropdownCombo2)
	ON_CBN_SELCHANGE(IDC_COMBO7, OnSelchangeCombo7)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_EN_KILLFOCUS(IDC_EDIT1, OnKillfocusEdit1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Setpar message handlers



BOOL Setpar::OnInitDialog() 
{
	
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	naccel=3;


	setpar_s8 = 24;
	
	//OnSelchangeCombo7();
	
  CheckRadioButton(IDC_RADIO4,IDC_RADIO6,IDC_RADIO6);
  CheckRadioButton(IDC_RADIO1,IDC_RADIO2,IDC_RADIO1);
  CheckRadioButton(IDC_RADIO3,IDC_RADIO5,IDC_RADIO5);  


	m_TDNo.SelectString(-1,s[8]);
	OnSelchangeCombo7();//提取上次选择值
	//m_xianbo.SelectString(-1,s[3]);
	if(s[3]=="开")
	{
		CheckRadioButton(IDC_RADIO3,IDC_RADIO5,IDC_RADIO3);
	}else
	{
		CheckRadioButton(IDC_RADIO3,IDC_RADIO5,IDC_RADIO5);
	}
	//m_cf.SelectString(-1,s[7]);
	if(s[7]=="内")
	{	
		CheckRadioButton(IDC_RADIO1,IDC_RADIO2,IDC_RADIO2);
	}else
	{
		CheckRadioButton(IDC_RADIO1,IDC_RADIO2,IDC_RADIO1);
	}
//	UpdateData(false);
	m_tongdao.SelectString(-1,s[0]);
    m_gaojie.SelectString(-1,s[1]);
	m_dijie.SelectString(-1,s[2]);
	m_caiycd.SelectString(-1,s[5]);
	m_caiyjg.SelectString(-1,s[4]);
	//m_caiyjg.SetWindowText (s[4]);    
	m_ys.SetWindowText(s[6]);
    //m_TDNo.SelectString(-1,s[8]);
	//OnSelchangeCombo7();
	//m_spin.SetBuddy(GetDlgItem(IDC_EDIT1));//通过方法绑定到EDIT1,注:spin按钮在EDIT1的下面
	m_spin.SetRange(0,9999);
    
	
	//m_spin.SetPos(1000);//设置 m_spin 控件的初值
	//m_spin.SetBase(16);//以16进制显示
	m_spin.GetAccel(naccel,paccel);//指针时用变量的引用
	
	paccel[0].nSec = 0;
	paccel[0].nInc = 1;
	paccel[1].nSec = 2;
	paccel[1].nInc = 100;	
	paccel[2].nSec = 5;
    paccel[2].nInc = 1000;
	
    m_spin.SetAccel(naccel,paccel);//(1)指针时用变量的引用
	//设置m_spin的变速器参数
	//m_spin.SetAccel(naccel,paccel+1);//(10)指针时用变量的引用

//  CheckRadioButton(IDC_RADIO4,IDC_RADIO6,IDC_RADIO6);
//  CheckRadioButton(IDC_RADIO1,IDC_RADIO2,IDC_RADIO1);
//  CheckRadioButton(IDC_RADIO3,IDC_RADIO5,IDC_RADIO5);  

    parcaiyangKey = false;

	if(m_butoon1Key)
	{
		m_butoon1.EnableWindow(false);
	}else
	{
		m_butoon1.EnableWindow(true);		
	}

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


void Setpar::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

void Setpar::OnOK() 
{
	// TODO: Add extra validation here
    int m_cfRadio;
	int m_xianboRadio;
	m_tongdao.GetWindowText(s[0]); //具体通道
	m_gaojie.GetWindowText(s[1]);
	m_dijie.GetWindowText(s[2]);
	//m_xianbo.GetWindowText(s[3]);
	m_xianboRadio = GetCheckedRadioButton(IDC_RADIO3,IDC_RADIO5);
	if(m_xianboRadio==IDC_RADIO3)
	{
		s[3] = "开";
	}else
	{
		s[3] = "关";
	}
	m_caiyjg.GetWindowText(s[4]);
	m_caiycd.GetWindowText(s[5]);
	m_ys.GetWindowText(s[6]);
	//m_cf.GetWindowText(s[7]);
	m_cfRadio = GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO2);
	if(m_cfRadio==IDC_RADIO1)
	{
		s[7] = "外";
	}else
	{
		s[7] = "内";
	}
	m_TDNo.GetWindowText(s[8]);  //通道数
    //暂存到文档类中,其他类都到文档类中去取

	//m_tongdao.SetWindowText(s);
	//m_xianbo.EnableWindow(false);

	//将参数发送到COM口
	channel_index = m_TDNo.GetCurSel();//通道数
	tongdao_index = m_tongdao.GetCurSel(); //具体
	jiange_index  = m_caiyjg.GetCurSel();
	length_index  = m_caiycd.GetCurSel();
	gaojie_index  = m_gaojie.GetCurSel();
	dijie_index   = m_dijie.GetCurSel();
    //chufa_index   = m_cf.GetCurSel();
	if(s[7]=="外")
	{
		chufa_index = 0;
	}else
	{
		chufa_index = 1;
	}
	//xianbo_index  = m_xianbo.GetCurSel();
	if(s[3]=="开")
	{
		xianbo_index = 0;
	}else
	{
		xianbo_index = 1;
	}
	//power_index =
	//zengy_index =
	//yanshi_time =
	//待加



	CDialog::OnOK();
}


void Setpar::OnDropdownCombo2() 
{
	/*int index_No;
	index_No = m_TDNo.GetCurSel();//当前选项的索引
	if (index_No==0)
	{  m_tongdao.ResetContent();
	   m_tongdao.AddString("1-2"); 
	   m_tongdao.AddString("2-4"); 
	   m_tongdao.AddString("5-6");
	   m_tongdao.AddString("7-8");
       m_tongdao.AddString("9-10");
	   m_tongdao.AddString("11-12");
	   m_tongdao.AddString("13-14");
	   m_tongdao.AddString("15-16");
	   m_tongdao.AddString("17-18");
	   m_tongdao.AddString("19-20");
	   m_tongdao.AddString("21-22");
	   m_tongdao.AddString("23-24");
	}
	   else if(index_No==1)
	   {      m_tongdao.ResetContent();
		      m_tongdao.AddString("1-6"); 
	          m_tongdao.AddString("7-12"); 
			  m_tongdao.AddString("13-18"); 
			  m_tongdao.AddString("19-24"); 			  
	   }
			  else if(index_No==2)
			  {      m_tongdao.ResetContent();
				     m_tongdao.AddString("1-12"); 
			         m_tongdao.AddString("13-24");          				 
					 
			  }
					 else //index_No = 24CH
					 {   m_tongdao.ResetContent();
						 m_tongdao.AddString("1-24"); 
					     
					 }
	*/
}

void Setpar::OnSelchangeCombo7() 
{
	int index_No;
	index_No = m_TDNo.GetCurSel();//当前选项的索引
	if (index_No==0)
	{  m_tongdao.ResetContent();
	   m_tongdao.AddString("1-2"); 
	   m_tongdao.AddString("3-4"); 
	   m_tongdao.AddString("5-6");
	   m_tongdao.AddString("7-8");
       m_tongdao.AddString("9-10");
	   m_tongdao.AddString("11-12");
	   m_tongdao.AddString("13-14");
	   m_tongdao.AddString("15-16");
	   m_tongdao.AddString("17-18");
	   m_tongdao.AddString("19-20");
	   m_tongdao.AddString("21-22");
	   m_tongdao.AddString("23-24");
	}
	   else if(index_No==1)
	   {      m_tongdao.ResetContent();
		      m_tongdao.AddString("1-6"); 
	          m_tongdao.AddString("7-12"); 
			  m_tongdao.AddString("13-18"); 
			  m_tongdao.AddString("19-24"); 			  
	   }
			  else if(index_No==2)
			  {      m_tongdao.ResetContent();
				     m_tongdao.AddString("1-12"); 
			         m_tongdao.AddString("13-24");          				 
					 
			  }
					 else //index_No = 24CH
					 {   m_tongdao.ResetContent();
						 m_tongdao.AddString("1-24"); 
					     
					 }
					 m_tongdao.SetCurSel(0);

	int index_No1;
	index_No1 = m_TDNo.GetCurSel();
	if (index_No1==0)
	{  m_caiyjg.ResetContent();
	   m_caiyjg.AddString("10 us"); 
	   m_caiyjg.AddString("25 us"); 
	   m_caiyjg.AddString("50 us");
	   m_caiyjg.AddString("100 us");
	   m_caiyjg.AddString("200 us");
	   m_caiyjg.AddString("500 us");
	   m_caiyjg.AddString("1ms");
	   m_caiyjg.AddString("2ms");
	   m_caiyjg.AddString("5ms");
	   m_caiyjg.AddString("10ms");
	   m_caiyjg.AddString("20ms");
	   m_caiyjg.SetCurSel(0);
       setpar_s8 = 2;
	}
	   else if(index_No1==1)
	   {        m_caiyjg.ResetContent();
			    m_caiyjg.AddString("25 us"); 
				m_caiyjg.AddString("50 us");
				m_caiyjg.AddString("100 us");
				m_caiyjg.AddString("200 us");
				m_caiyjg.AddString("500 us");
				m_caiyjg.AddString("1ms");
				m_caiyjg.AddString("2ms");
				m_caiyjg.AddString("5ms");
				m_caiyjg.AddString("10ms");
				m_caiyjg.AddString("20ms");
				m_caiyjg.SetCurSel(3);

			  setpar_s8 = 6;
	   }
			  else if(index_No1==2) //index_No = 12CH
			  {      m_caiyjg.ResetContent();
				     m_caiyjg.AddString("50 us");
					 m_caiyjg.AddString("100 us");
					 m_caiyjg.AddString("200 us");
					 m_caiyjg.AddString("500 us");
					 m_caiyjg.AddString("1ms");
					 m_caiyjg.AddString("2ms");
					 m_caiyjg.AddString("5ms");
					 m_caiyjg.AddString("10ms");
					 m_caiyjg.AddString("20ms");
					 m_caiyjg.SetCurSel(2);
					 
					 setpar_s8 = 12;
			  }
					 else //index_No = 24CH
					 {  m_caiyjg.ResetContent();
						m_caiyjg.AddString("100 us");
						m_caiyjg.AddString("200 us");
						m_caiyjg.AddString("500 us");
						m_caiyjg.AddString("1ms");
						m_caiyjg.AddString("2ms");
						m_caiyjg.AddString("5ms");
						m_caiyjg.AddString("10ms");
						m_caiyjg.AddString("20ms");
						m_caiyjg.SetCurSel(1);
	   
						 setpar_s8 = 24;
					 }
					 //m_caiyjg.SetCurSel(0);	


   int index_No2;
	index_No2 = m_TDNo.GetCurSel();
	if (index_No2==0)
	{  m_caiycd.ResetContent();
	   m_caiycd.AddString("512"); 
	   m_caiycd.AddString("1024"); 
	   m_caiycd.AddString("2048");
	   m_caiycd.AddString("4096");
	   m_caiycd.AddString("8192");
	   m_caiycd.AddString("16384");
	   //m_caiycd.AddString("114k");
	  // m_caiycd.AddString("114000");
	   //m_caiycd.AddString("334k");
	  // m_caiycd.AddString("334000");
	   m_caiycd.SetCurSel(3);	
	   
       setpar_s8 = 2;
	}
	   else if(index_No2==1)
	   {      
			  m_caiycd.ResetContent();
		      m_caiycd.AddString("512"); 
			  m_caiycd.AddString("1024"); 
	          m_caiycd.AddString("2048");
	          m_caiycd.AddString("4096");
	          m_caiycd.AddString("8192");
	          m_caiycd.AddString("16384");
			  //m_caiycd.AddString("114k");
			  //m_caiycd.AddString("114000");
			   m_caiycd.SetCurSel(2);	
	   
			  setpar_s8 = 6;
	   }
			  else if(index_No1==2)
			  {  
				  m_caiycd.ResetContent();
				  m_caiycd.AddString("512"); 
			      m_caiycd.AddString("1024"); 
	              m_caiycd.AddString("2048");
	              m_caiycd.AddString("4096");
	              m_caiycd.AddString("8192");
	              m_caiycd.AddString("16384");
				  m_caiycd.SetCurSel(2);	
			  	 
					 setpar_s8 = 12;
			  }
			  else //if(index_No1==3)
			  {  
				  m_caiycd.ResetContent();
				  m_caiycd.AddString("512"); 
			      m_caiycd.AddString("1024"); 
	              m_caiycd.AddString("2048");
	              m_caiycd.AddString("4096");
	              m_caiycd.AddString("8192");
	              m_caiycd.AddString("16384");
				  m_caiycd.SetCurSel(2);	
			  	 
					 setpar_s8 = 24;
			  }
					// m_caiycd.SetCurSel(0);	

}

void Setpar::OnButton1() 
{
	OnOK();
	parcaiyangKey = true;
}

void Setpar::OnKillfocusEdit1() 
{	
	CString s;
	m_ys.GetWindowText(s);	
	if(s.GetLength() >4 || atoi(s) > 9999 || atoi(s) < 0 ) 
	{
		MessageBox("  >= 0 AND <= 9999 以毫秒为单位的整数 (ms)! ");	//应该是6Db的加数
		GetDlgItem(IDC_EDIT1)->SetFocus();
		m_ys.SetWindowText(""); 
		
		//m_ys.SetSel(1,2);
	}
			
	//UpdateData(false);
		
}

//DEL void Setpar::OnChangeEdit1() 
//DEL {
//DEL 
//DEL 	CString s;
//DEL 	//m_ys.GetWindowText(s);
//DEL //	s.Right( 1 ) ;
//DEL 	
//DEL /*	if(atoi(s) > 9 || atoi(s) < 0 ) 
//DEL 	{
//DEL 		MessageBox("  >= 0 AND <= 9 的数字! ");	//应该是6Db的加数
//DEL 		GetDlgItem(IDC_EDIT1)->SetFocus();
//DEL 		m_ys.SetWindowText(""); 
//DEL 	}
//DEL 
//DEL 
//DEL */	
//DEL 	
//DEL }


⌨️ 快捷键说明

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