
cb->AddString("一项文字")
cb->InsertString(0,"文字");
cd->DeleteString(编号)
修改就删除再插入就行了吧
现在不清楚你是否是使用双缓冲做的这个,如果是的话基本上在ondraw函数中会使用bitblt这个函数拷贝图片,你可以在这里通过逻辑控制如果需要显示文字内容的时候就不拷贝这个图片,如果是其他方法实现的那需要具体情况具体定了。一。首先新建一个Single或者对话框类型的MFC.EXE工种。二。插入一个Dialog,然后新建一个类CDlgList,可以利用这个控件显示项目,也可实现多选,得到选项总数等.其源程序如下:
// DlgList.cpp : implementation file
//
#include "stdafx.h"
#include "testvc.h"
#include "DlgList.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgList dialog
CDlgList::CDlgList(CWnd* pParent /*=NULL*/)
: CDialog(CDlgList::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgList)
//}}AFX_DATA_INIT
}
void CDlgList::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX)
//{{AFX_DATA_MAP(CDlgList)
DDX_Control(pDX, IDC_BUTTON1, m_Del)
DDX_Control(pDX, IDC_EDIT1, m_Edit)
DDX_Control(pDX, IDC_LIST1, m_Lst)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgList, CDialog)
//{{AFX_MSG_MAP(CDlgList)
ON_BN_CLICKED(IDC_BUTTON1, OnAddString)
ON_BN_CLICKED(IDC_BUTTON2, OnDel)
ON_BN_CLICKED(IDC_BUTTON5, OnClear)
ON_BN_CLICKED(IDC_BUTTON3, OnGetCount)
ON_BN_CLICKED(IDC_BUTTON4, OnGetCurSel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgList message handlers
void CDlgList::OnAddString()
{
// TODO: Add your control notification handler code here
CString str
m_Edit.GetWindowText(str)
m_Lst.AddString(str)
UpdateData(FALSE)
}
int CDlgList::DoModal()
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DoModal()
}
void CDlgList::OnDel()
{
// TODO: Add your control notification handler code here
m_Lst.DeleteString(m_Lst.GetCurSel())
UpdateData(FALSE)
}
void CDlgList::OnClear()
{
// TODO: Add your control notification handler code here
for(int i=0i<m_Lst.GetCount()i++)
{m_Lst.DeleteString(i)i--}
UpdateData(FALSE)
}
void CDlgList::OnGetCount()
{
// TODO: Add your control notification handler code here
CString str
str.Format("List中共有%d项",m_Lst.GetCount())
AfxMessageBox(str)
}
void CDlgList::OnGetCurSel()
{
// TODO: Add your control notification handler code here
// AfxMessageBox(str)
CString str,strMess
for (int i=0i <m_Lst.GetCount()i++)
{
str.Format(_T("item %d: 您的选择状态是%s\r\n"),i,m_Lst.GetSel( i ) >0 ? _T("true") : _T("false"))
afxDump <<str
strMess+=str
}
AfxMessageBox(strMess)
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)