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

📄 checkboxdlg.cpp

📁 接上面那个
💻 CPP
字号:
// CheckBoxDlg.cpp : implementation file
//

#include "stdafx.h"
#include "exam7_3.h"
#include "CheckBoxDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCheckBoxDlg dialog


CCheckBoxDlg::CCheckBoxDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCheckBoxDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCheckBoxDlg)
	m_check1 = FALSE;
	m_check2 = FALSE;
	m_check3 = FALSE;
	m_edit = _T("");
	//}}AFX_DATA_INIT
}


void CCheckBoxDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCheckBoxDlg)
	DDX_Check(pDX, IDC_CHECK1, m_check1);
	DDX_Check(pDX, IDC_CHECK2, m_check2);
	DDX_Check(pDX, IDC_CHECK3, m_check3);
	DDX_Text(pDX, IDC_EDIT1, m_edit);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCheckBoxDlg, CDialog)
	//{{AFX_MSG_MAP(CCheckBoxDlg)
	ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
	ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
	ON_BN_CLICKED(IDC_CHECK3, OnCheck3)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCheckBoxDlg message handlers

BOOL CCheckBoxDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
		
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CCheckBoxDlg::OnCheck1() 
{// TODO: Add your control notification handler code here
	m_check1=!m_check1;	
	CheckState();
	UpdateData(FALSE);
	}

void CCheckBoxDlg::OnCheck2() 
{
	// TODO: Add your control notification handler code here
	m_check2=!m_check2;	
	CheckState();
	UpdateData(FALSE);
	
}

void CCheckBoxDlg::OnCheck3() 
{
	// TODO: Add your control notification handler code here
	m_check3=!m_check3;	
	CheckState();
	UpdateData(FALSE);
	
}

void CCheckBoxDlg::CheckState()
{
    m_edit="None of checkbox has been selected";
	if(m_check1) m_edit="Check1 has been selected";		
	if(m_check2) m_edit="Check2 has been selected";		
	if(m_check3) m_edit="Check3 has been selected";		
	if(m_check1&&m_check2)			
		m_edit="Check1 and Check2 have been selected";
	if(m_check1&&m_check3)			
		m_edit="Check1 and Check3 have been selected";
	if(m_check2&&m_check3)			
		m_edit="Check2 and Check3 have been selected";
	if(m_check1&&m_check2&&m_check3)			
		m_edit="All checkbox have been selected";

}

⌨️ 快捷键说明

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