checkboxdlg.cpp

来自「This is Visual C++ basis operation. Usin」· C++ 代码 · 共 104 行

CPP
104
字号
// 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 + =
减小字号Ctrl + -
显示快捷键?