randomfilterdlg.cpp

来自「某个实验事编写粗糙集智能信息处理的程序」· C++ 代码 · 共 100 行

CPP
100
字号
// RandomFilterDlg.cpp : implementation file
//

#include "stdafx.h"
#include "rset.h"
#include "RandomFilterDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CRandomFilterDlg dialog


CRandomFilterDlg::CRandomFilterDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CRandomFilterDlg::IDD, pParent)
{
	m_nTotalNumber=0;
	//{{AFX_DATA_INIT(CRandomFilterDlg)
	m_Number = 0;
	m_Percent = 0.0;
	m_Message = _T("");
	//}}AFX_DATA_INIT
}


void CRandomFilterDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CRandomFilterDlg)
	DDX_Text(pDX, IDC_NUMBER, m_Number);
	DDX_Text(pDX, IDC_PERCENT, m_Percent);
	DDX_Text(pDX, IDC_MESSAGE, m_Message);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CRandomFilterDlg, CDialog)
	//{{AFX_MSG_MAP(CRandomFilterDlg)
	ON_EN_CHANGE(IDC_NUMBER, OnChangeNumber)
	ON_EN_CHANGE(IDC_PERCENT, OnChangePercent)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRandomFilterDlg message handlers

BOOL CRandomFilterDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_Message.Format("数据集中共包含 %d 条数据,请输入要筛选出来的数据条数或者百分比。",m_nTotalNumber);
	UpdateData(false);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CRandomFilterDlg::OnChangeNumber() 
{
	// 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.
	
	// TODO: Add your control notification handler code here
	UpdateData();
    if(m_Number>m_nTotalNumber)
	{
		AfxMessageBox("请输入不超过样本范围的数字");
		m_Percent=0;
        m_Number=0;
	}
	else	m_Percent=m_Number*100/m_nTotalNumber;
	UpdateData(false);
}



void CRandomFilterDlg::OnChangePercent() 
{
	// 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.
	
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_Percent>100)
	{
		AfxMessageBox("请输入1—100之间的数");
		m_Percent=0;
        m_Number=0;
	}
	else m_Number=m_Percent*m_nTotalNumber/100;
	UpdateData(false);
}

⌨️ 快捷键说明

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