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

📄 sysdialog.cpp

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

#include "stdafx.h"
#include "cge.h"
#include "Sysdialog.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSysdialog dialog


CSysdialog::CSysdialog(CWnd* pParent /*=NULL*/)
	: CDialog(CSysdialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSysdialog)
	m_strYbegin = _T("");
	m_strYend = _T("");
	m_strXbegin = _T("");
	m_strXend = _T("");
	//}}AFX_DATA_INIT
}


void CSysdialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSysdialog)
	DDX_Control(pDX, IDC_COMBO2, m_lpt);
	DDX_Control(pDX, IDC_COMBO1, m_com);
	DDX_Text(pDX, IDC_EDIT2, m_strYbegin);
	DDX_Text(pDX, IDC_EDIT3, m_strYend);
	DDX_Text(pDX, IDC_EDIT4, m_strXbegin);
	DDX_Text(pDX, IDC_EDIT5, m_strXend);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSysdialog, CDialog)
	//{{AFX_MSG_MAP(CSysdialog)
	ON_EN_CHANGE(IDC_EDIT4, OnChangeEdit4)
	ON_EN_CHANGE(IDC_EDIT5, OnChangeEdit5)
	ON_EN_KILLFOCUS(IDC_EDIT2, OnKillfocusEdit2)
	ON_EN_KILLFOCUS(IDC_EDIT3, OnKillfocusEdit3)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSysdialog message handlers

void CSysdialog::OnOK() 
{
	m_com.GetWindowText(m_strcom); 
	m_lpt.GetWindowText(m_strlpt);
	
	CDialog::OnOK();
}

BOOL CSysdialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_com.SelectString(-1,m_strcom);
	m_lpt.SelectString(-1,"378"); //m_strlpt);	

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


void CSysdialog::OnChangeEdit4() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	UpdateData(true);
	if(atoi(m_strXbegin) < -5 || atoi(m_strXbegin) > 3 ) 
	{
		MessageBox("  >=-5 AND <= 3");
		m_strXbegin = ""; 
		UpdateData(false);
	}
	
}

void CSysdialog::OnChangeEdit5() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	UpdateData(true);
	if(atoi(m_strXend) > 3 || atoi(m_strXend) < -5 ) 
	{
		MessageBox("  <= 3 AND >= -5");
		m_strXend = ""; //m_strXend.Left(1);
		UpdateData(false);
	}
	
}

void CSysdialog::OnKillfocusEdit2() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	if(atoi(m_strYbegin) < -60 || atoi(m_strYbegin) > 0 ) 
	{
		MessageBox("  >= -60 AND <= 0 并且是6的倍数! ");	//应该是6Db的加数
		GetDlgItem(IDC_EDIT2)->SetFocus();
		m_strYbegin = ""; 
	}
	else //if(atoi(m_strYbegin)%6 != 0)
	{
		m_strYbegin.Format("%d",atoi(m_strYbegin)-atoi(m_strYbegin)%6);
	}
			
	UpdateData(false);
	
}

void CSysdialog::OnKillfocusEdit3() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	
	if(atoi(m_strYend) > 60 || atoi(m_strYend) < 0 ) 
	{
		MessageBox(" <= 60 AND >= 0 并且是6的倍数! ");	
		GetDlgItem(IDC_EDIT3)->SetFocus();
		m_strYend = "";  
		
	}
		else //if(atoi(m_strYbegin)%6 != 0)
	{
		m_strYend.Format("%d",atoi(m_strYend)-atoi(m_strYend)%6);
	}
	
	UpdateData(false);
}

⌨️ 快捷键说明

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