www.pudn.com > ManyControl.rar > ModalDlg.cpp


// ModalDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "MyDialog.h" 
#include "ModalDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CModalDlg dialog 
 
 
CModalDlg::CModalDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CModalDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CModalDlg) 
	m_Text = _T(""); 
	//}}AFX_DATA_INIT 
} 
 
 
void CModalDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CModalDlg) 
	DDX_Control(pDX, IDC_LIST_EXAMPLE, m_pList); 
	DDX_Control(pDX, IDC_COMBO_EXAMPLE, m_pCombo); 
	DDX_Text(pDX, IDC_EDIT_TEXT, m_Text); 
	DDV_MaxChars(pDX, m_Text, 100); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CModalDlg, CDialog) 
	//{{AFX_MSG_MAP(CModalDlg) 
	ON_CBN_SELCHANGE(IDC_COMBO_EXAMPLE, OnSelchangeComboExample) 
	ON_LBN_SELCHANGE(IDC_LIST_EXAMPLE, OnSelchangeListExample) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CModalDlg message handlers 
 
void CModalDlg::OnSelchangeComboExample()  
{ 
	// TODO: Add your control notification handler code here 
	int m_nSel=m_pCombo.GetCurSel(); 
	CString str[4]={"第一项","第二项","第三项","第四项"}; 
	CString str_Sel="你选择了组合框中"+str[m_nSel]; 
	AfxMessageBox(str_Sel); 
} 
 
void CModalDlg::OnSelchangeListExample()  
{ 
	// TODO: Add your control notification handler code here 
	int m_nSel=m_pList.GetCurSel(); 
	CString str[4]={"第一项","第二项","第三项","第四项"}; 
	CString str_Sel="你选择了列表框中"+str[m_nSel]; 
	AfxMessageBox(str_Sel); 
	 
} 
 
BOOL CModalDlg::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	m_pList.AddString("第一项"); 
	m_pList.AddString("第二项"); 
	m_pList.AddString("第三项"); 
	m_pList.AddString("第四项"); 
 
	m_pCombo.SetCurSel(0); 
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
}