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

📄 listdlg.cpp

📁 控件的使用源代码。打开后可实现控件的应用 。
💻 CPP
字号:
// ListDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ControlExample.h"
#include "ListDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CListDlg dialog


CListDlg::CListDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CListDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CListDlg)
	m_EditPoem = _T("");
	//}}AFX_DATA_INIT
}


void CListDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CListDlg)
	DDX_Control(pDX, IDC_LIST_NAME, m_ListName);
	DDX_Text(pDX, IDC_EDIT_POEM, m_EditPoem);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CListDlg, CDialog)
	//{{AFX_MSG_MAP(CListDlg)
	ON_LBN_SELCHANGE(IDC_LIST_NAME, OnSelchangeListName)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListDlg message handlers

void CListDlg::OnSelchangeListName() 
{
	// TODO: Add your control notification handler code here
	int nIndex=m_ListName.GetCurSel();
	if(nIndex!=LB_ERR)
	{
		switch(nIndex)
		{
		case 0:
			m_EditPoem="床前明月光,\r\n疑似地上霜。";
			break;
		case 1:
			m_EditPoem="借问酒家何处有,\r\n牧童遥指杏花村。";
			break;			
		}
		UpdateData(FALSE);
	}
}

BOOL CListDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//初始化列表控件
	m_ListName.AddString("李白");
	m_ListName.AddString("杜甫");
	UpdateData(FALSE);
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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