ex050102cdlg.cpp

来自「深入浅出Visual C++入门进阶与应用实例 随书光盘 作者 何志丹」· C++ 代码 · 共 75 行

CPP
75
字号
// Ex050102cDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ex050102c.h"
#include "Ex050102cDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CEx050102cDlg dialog


CEx050102cDlg::CEx050102cDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CEx050102cDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CEx050102cDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CEx050102cDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CEx050102cDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CEx050102cDlg, CDialog)
	//{{AFX_MSG_MAP(CEx050102cDlg)
	ON_BN_CLICKED(IDC_CHECK, OnCheck)
	ON_BN_CLICKED(IDC_GETSTATE, OnGetstate)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEx050102cDlg message handlers

void CEx050102cDlg::OnOK() 
{
	// TODO: Add extra validation here
	
	CDialog::OnOK();
}

void CEx050102cDlg::OnCheck() 
{
	CheckDlgButton(IDC_CHECK1,2);
	CheckRadioButton(IDC_RADIO1,IDC_RADIO3,IDC_RADIO2);
}

void CEx050102cDlg::OnGetstate() 
{
	CString strMess ;
	if(IsDlgButtonChecked(IDC_CHECK1))
		strMess = "复选框被选中\n";
	else
		strMess = "复选框没有被选中\n";
	
	UINT uID = GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO3);
	CString strRadioText ;
	GetDlgItemText(uID,strRadioText);
	if(!strRadioText.IsEmpty())
		strMess += "选中了单选框" + strRadioText ;
	
	AfxMessageBox(strMess);	
}

⌨️ 快捷键说明

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