高手看看这段代码错在哪里?谢谢!!

yeyuanzhi2008 2009-04-19 04:37:07
在CConferenceDialog对话框建立了派生于CListCtrlEX类的m_olist控件,
然后在CMainFrame.h中声明
CConferenceDialog dlgBar;
在CMainFrame.cpp中的代码是:
void CMainFrame::OnAddMember(WPARAM wParam, LPARAM lParam)
{
CString* pStr = (CString*)wParam;
this->dlgBar.m_olist.SetItemText((short)lParam, pStr->GetBuffer(0), NULL);
pStr->ReleaseBuffer();
}

CMainFrame::OnRemoveMember(WPARAM wParam, LPARAM lParam)
{
CString* pStr = (CString*)wParam;
if(!pStr->CompareNoCase("DUMP"))
this->dlgBar.m_olist.DeleteAllItems();
else
this->dlgBar.m_olist.Remove(pStr->GetBuffer(0));
pStr->ReleaseBuffer();
}



编译出错:
C:\MainFrm.cpp(1273) : warning C4101: 'sz' : unreferenced local variable
C:\MainFrm.cpp(2663) : error C2664: 'SetItemText' : cannot convert parameter 2 from 'char *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\MainFrm.cpp(2673) : error C2039: 'Remove' : is not a member of 'CListCtrlEx'
c:\listctrlex.h(13) : see declaration of 'CListCtrlEx'
不知是什么问题,请高手出招,谢谢!!
...全文
132 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xtjqu 2009-04-19
  • 打赏
  • 举报
回复
顺手了,应该这样
pStr->GetBuffer(0) ---> *pStr
this->dlgBar.m_olist.Remove(pStr->GetBuffer(0)); -->this->dlgBar.m_olist.DeleteItem((short)lParam)
xtjqu 2009-04-19
  • 打赏
  • 举报
回复
pStr->GetBuffer(0) ---> &pStr
this->dlgBar.m_olist.Remove(pStr->GetBuffer(0)); -->this->dlgBar.m_olist.DeleteItem((short)lParam)
zteclx 2009-04-19
  • 打赏
  • 举报
回复
1、pStr->GetBuffer(0), char ——》 int……
2、CListCtrlEx中没有REMOVE这个方法;
yeyuanzhi2008 2009-04-19
  • 打赏
  • 举报
回复
不好意思,本人有点笨拙,请多多指点!!
黄志义 2009-04-19
  • 打赏
  • 举报
回复
这样的错误还要问 别人还怎么跟你解释呢? 帮你把英文错误描述翻译成中文?
yeyuanzhi2008 2009-04-19
  • 打赏
  • 举报
回复
具体怎么修改?我修改成this->dlgBar.m_olist.SetItemText((short)lParam, NULL,pStr->GetBuffer(0))后是没问题了,但是还是显示不出数据啊?
qwang24 2009-04-19
  • 打赏
  • 举报
回复
这是非常简单的错误:

error 1: 按SetItemText的申明,第二参数为整型,第三个参数为LPCTSTR,你传错顺序了。
BOOL SetItemText(
int nItem,
int nSubItem,
LPCTSTR lpszText
);

error 2: CListCtrlEx没有定义Remove方法,所以调用失败。

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧