CListCtrl& listctrl=GetListCtrl();出现问题

来源:百度知道 编辑:UC知道 时间:2024/06/26 06:09:39
我在视类中添加如下代码:
CListCtrl& listctrl=GetListCtrl();
提示错误:'GetListCtrl' : undeclared identifier
请问怎么改正??
CListCtrl& listctrl=GetListCtrl();
listctrl.InsertColumn(0, "房间号", LVCFMT_LEFT, 50, 6);
listctrl.InsertColumn(1, " 开始时间", LVCFMT_LEFT, 80, 6);
listctrl.InsertColumn(2, " 结束时间", LVCFMT_LEFT, 80, 6);
listctrl.InsertColumn(3, " 总共用间", LVCFMT_LEFT, 80, 6);
listctrl.InsertColumn(4, " 是否在线", LVCFMT_LEFT, 80, 6);
listctrl.InsertColumn(5, " 应付费用", LVCFMT_LEFT, 80, 6);
listctrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
这是一光盘上的原码,能正确运行显示列表,但是我复制到自己工程的相应位置,编译通过但是列表不显示出来,两位的方法我都试过了不行啊!谢谢你们仔细考虑一下!

1、你的视类是从CListView继承的吗?
2、你的这段代码写在那个函数里了?

补充:
要Modify成LVS_REPORT类型

listctrl.ModifyStyle(0,LVS_REPROT);

哥们发你的源码过来瞧瞧吧。
29377747@qq.com

用this->查看是否有此函数,没有说明不是从ClistView派生的,要改为从此基类派生。

BOOL CYourListView::PreCreateWindow(CREATESTRUCT& cs)
{
// the CREATESTRUCT cs
cs.style |= LVS_REPORT|WS_VISIBLE;

return CListView::PreCreateWindow(cs);
}

void CYourListView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CMDIChildWnd *pWnd=(CMDIChildWnd *)GetParentFrame();
ASSERT( pWnd != NULL);
pWnd->MDIMaximize(); //最大化子窗体
// TODO: You may populate your ListView with items by directly accessing
CListCtrl& listctrl=GetListCtrl();
listctrl.InsertColumn(0, "房间号", LVCFMT_LEFT, 50, 6);
listctrl.InsertColumn(1, " 开始时间", LVCFMT_LEFT, 80, 6);
ListView_SetExtendedListViewStyle(listctrl.m_hWnd, LVS_EX_FULLROWSEL