GetListCtrl()是哪个门派的?

trial 2002-08-05 12:45:46
我想把数据库中的数据显示出来其中用了“CListCtrl& ctrllist=(CListCtrl&)GetListCtrl();这条语句,可是编译的时候提示说D:\Code\Manage\ManageView.cpp(86) : error C2065: 'GetListCtrl' : undeclared identifier
在这个情况下要怎么处理它
...全文
306 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhuojohn 2002-08-05
  • 打赏
  • 举报
回复
解决方法
=========================
在afxstd.h加入
#include <afxcview.h>即可
wuxuan 2002-08-05
  • 打赏
  • 举报
回复
Call this member function to get a reference to the list control associated with the view.

CListCtrl& GetListCtrl( ) const;
Return Value
A reference to the list control associated with the view.

Example
void CMyListView::OnInitialUpdate()
{
CListView::OnInitialUpdate();

// this code only works for a report-mode list view
ASSERT(GetStyle() & LVS_REPORT);

// Gain a reference to the list control itself
CListCtrl& theCtrl = GetListCtrl();

// Insert a column. This override is the most convenient.
theCtrl.InsertColumn(0, _T("Player Name"), LVCFMT_LEFT);

// The other InsertColumn() override requires an initialized
// LVCOLUMN structure.
LVCOLUMN col;
col.mask = LVCF_FMT | LVCF_TEXT;
col.pszText = _T("Jersey Number");
col.fmt = LVCFMT_LEFT;
theCtrl.InsertColumn(1, &col);

// Set reasonable widths for our columns
theCtrl.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
theCtrl.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
}
wuxuan 2002-08-05
  • 打赏
  • 举报
回复
“identifier”: 未声明的标识符

在可使用变量的类型前必须在声明中指定它。在可以使用函数前必须在声明或原型中指定该函数使用的参数。

可能的原因

可能正在调用当前不受生成环境支持的 SDK 头文件中的函数。
省略必要的包含文件,尤其是在定义 VC_EXTRALEAN、WIN32_LEAN_AND_MEAN 或 WIN32_EXTRA_LEAN 时。这些符号从 windows.h 和 afxv_w32.h 中排除了一些头文件以加快编译。(在 windows.h 和 afxv_w32.h 中查找排除的头文件的最新说明。)
标识符名拼写错误。
标识符使用了错误的大小写字母。
字符串常数的后面缺少右引号。
字符串常数中的换行符没有继续符:
// C2065a.cpp
#include <stdio.h>
main() {
printf("\n %s
%s // C2065, 's' : undeclared identifier
%s",
"this", "is", "it");
}
在若干行上拆分常数字符串时要特别小心。一种方法是更改格式字符串。仅由空白(空格、Tab 键、换行符)分隔的字符串被连接起来:

#include <stdio.h>
main() {
printf("\n %s"
" %s"
" %s",
"this", "is", "it");
}
不太可取的一种方法是在行尾使用反斜杠。每个连续行开头处的空格成为字符串的组成部分:

printf("\n %s\
%s\
%s",
"this", "is", "it");
命名空间范围不正确。例如,若要解析 ANSI C++ 标准库函数和运算符,则必须用 using 指令指定 std 命名空间。下面的示例未能编译,因为 using 指令被注释掉,并且在 std 命名空间中定义了 cout:
// C2065c.cpp
#include <iostream>
// using namespace std;
void main()
{
cout << "Hello" << endl; // C2065
}

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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