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

📄 listboxdlg.cpp

📁 《VC++ 编程技巧与示例 .rar》各个示例代码绝对可用
💻 CPP
字号:
// ListBoxDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ControlTest.h"
#include "ListBoxDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CListBoxDlg dialog


CListBoxDlg::CListBoxDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CListBoxDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CListBoxDlg)
	//}}AFX_DATA_INIT
}


void CListBoxDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CListBoxDlg)
	DDX_Control(pDX, IDC_LIST, m_ListBox);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CListBoxDlg, CDialog)
	//{{AFX_MSG_MAP(CListBoxDlg)
	ON_LBN_DBLCLK(IDC_LIST, OnDblclkList)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListBoxDlg message handlers

void CListBoxDlg::AddString(CString str)
{
	m_ListBox.AddString(str);
}

BOOL CListBoxDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	// TODO: Add extra initialization here
	CString str;
	str="姓名:     "+m_Name;
	m_ListBox.AddString(str);
	str="年龄:     "+m_Age;
	m_ListBox.AddString(str);
	str="性别:     "+m_Male;
	m_ListBox.AddString(str);
	str="生日:    "+m_Date.Format ("%A, %B %d, %Y");
	m_ListBox.AddString(str);
	str="职业:     "+m_Career;
	m_ListBox.AddString(str);
	str="爱好:     "+m_treeitem;
	m_ListBox.AddString(str);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CListBoxDlg::OnDblclkList() 
{
	// TODO: Add your control notification handler code here
	UINT sel;
	CString str;
	sel=m_ListBox.GetCurSel();
	m_ListBox.GetText(sel,str);
	str="当前的选择是: "+str;
	AfxMessageBox(str);
}

⌨️ 快捷键说明

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