CList控件初始化的问题? 一般用AddString都可以,,估计:)呵呵,,是你在资源编辑器中没有设置listctrl的下拉长度吧,,我也犯过这种错误:)你在资源编辑器中选中listctrl然后点击右侧的小三角。在将这是出现的矩形虚线拉长,就可以了:) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 void CAboutDlg::OnButton1() { // TODO: Add your control notification handler code here CComboBox* pCtrl1 = (CComboBox*) GetDlgItem(IDC_LIST1); pCtrl1->AddString ("DFJKA"); UpdateData(false);}这是我的程序 你试试debug一下,单步执行一下CComboBox* pCtrl1 = (CComboBox*) GetDlgItem(IDC_LIST1); 应该是没有得到相关的指针,建议用classwizard增加相应的变量比较简单。 我用CTreeCtrl控件试过,这种方法是可以的! // The pointer to my list box.extern CListBox* pmyListBox;// Add 10 items to the list box.CString str;for (int i=0;i < 10;i++){ str.Format(_T("item string %d"), i); pmyListBox->AddString( str );} CListBox* pCtrl1 = (CListBox*) GetDlgItem(IDC_LIST1); pCtrl1->AddString ("DFJKA");********************************************把CComboBox换成CListBox试试 void CAboutDlg::OnButton1() { // TODO: Add your control notification handler code here //2002.03.11 ADD 1 LINE DELETE 1 LINE -->//DEL CComboBox* pCtrl1 = (CComboBox*) GetDlgItem(IDC_LIST1); CListBox* pCtrl1 = (CListBox*) GetDlgItem(IDC_LIST1); //2002.03.11 ADD 1 LINE DELETE 1 LINE <--pCtrl1->AddString ("DFJKA"); UpdateData(false); } 奇怪了,你到底是ListBox还是ComboBox啊,ListBox还有下拉的? void CAboutDlg::OnButton1() { // TODO: Add your control notification handler code here CComboBox* pCtrl1 = (CComboBox*) GetDlgItem(IDC_LIST1); pCtrl1->AddString ("DFJKA"); UpdateData(false);}这是我的程序,我在上面贴过的! 求串口通信模拟键盘操作 CPU占用率过高,求解决方案 进来看真相:XX王千源,叉叉卖国贼,打倒女汉奸!! 怎么给共享区域的数据加锁! 请问如何获取其它进程中已创建的DirectDraw对象? 调用简单的DLL的错误 如何分解一个超过10M的运用程序呢! 哪里有“c++程序设计实验指导”书下载? 关于MFC的迷茫,请路过的大神、大仙、大牛、前辈指点 键盘响应问题? 大家帮忙:如何实现这样一个既特殊又很平常的窗体。诚心邀请:来者有分,提出好议见者高分。 哪位大是知道,下面的内存泄露如何处理呢?不知道是哪里的原因,帮忙看看!!!
{
// TODO: Add your control notification handler code here
CComboBox* pCtrl1 = (CComboBox*) GetDlgItem(IDC_LIST1);
pCtrl1->AddString ("DFJKA");
UpdateData(false);
}
这是我的程序
CComboBox* pCtrl1 = (CComboBox*) GetDlgItem(IDC_LIST1);
应该是没有得到相关的指针,建议用classwizard增加相应的变量比较简单。
extern CListBox* pmyListBox;// Add 10 items to the list box.
CString str;
for (int i=0;i < 10;i++)
{
str.Format(_T("item string %d"), i);
pmyListBox->AddString( str );
}
pCtrl1->AddString ("DFJKA");
********************************************
把CComboBox换成CListBox试试
{
// TODO: Add your control notification handler code here
//2002.03.11 ADD 1 LINE DELETE 1 LINE -->
//DEL CComboBox* pCtrl1 = (CComboBox*) GetDlgItem(IDC_LIST1);
CListBox* pCtrl1 = (CListBox*) GetDlgItem(IDC_LIST1);
//2002.03.11 ADD 1 LINE DELETE 1 LINE <--
pCtrl1->AddString ("DFJKA"); UpdateData(false);
}
{
// TODO: Add your control notification handler code here
CComboBox* pCtrl1 = (CComboBox*) GetDlgItem(IDC_LIST1);
pCtrl1->AddString ("DFJKA");
UpdateData(false);
}
这是我的程序,我在上面贴过的!