ComboExDemoDlg.cpp
资源名称:ComboBox.rar [点击查看]
上传用户:hbjdyb2005
上传日期:2021-01-26
资源大小:168k
文件大小:1k
源码类别:
组合框控件
开发平台:
Visual C++
- // ComboExDemoDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ComboExDemo.h"
- #include "ComboExDemoDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CComboExDemoDlg dialog
- CComboExDemoDlg::CComboExDemoDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CComboExDemoDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CComboExDemoDlg)
- //}}AFX_DATA_INIT
- }
- void CComboExDemoDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CComboExDemoDlg)
- DDX_Control(pDX, IDC_COMBO, m_ComboBox);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CComboExDemoDlg, CDialog)
- //{{AFX_MSG_MAP(CComboExDemoDlg)
- ON_CBN_SELCHANGE(IDC_COMBO, OnSelchangeCombo)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CComboExDemoDlg message handlers
- BOOL CComboExDemoDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- m_ComboBox.AddString("Apples");
- m_ComboBox.AddString("bananas");
- m_ComboBox.AddString("oranges");
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CComboExDemoDlg::OnOK()
- {
- CString str;
- m_ComboBox.GetWindowText(str);
- AfxMessageBox(str);
- if (m_ComboBox.FindStringExact(-1, str) == CB_ERR)
- m_ComboBox.AddString(str);
- }
- void CComboExDemoDlg::OnSelchangeCombo()
- {
- TRACE0("Selection has changedn");
- }