为什么不能将ListCtrl的column取到?

南风1 2003-08-21 06:54:08
我用GetColumn函数想取column的标题(pszText)属性,column.mask = LVCF_TEXT,
但是GetColumn一直返回FALSE,而用msdn中的例子取column的宽度(cx)属性却是一直调用成功的,不知为什么,郁闷中!
...全文
32 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
bzpscu 2003-08-25
  • 打赏
  • 举报
回复
CListCtrl::GetColumn
BOOL GetColumn( int nCol, LVCOLUMN* pColumn ) const;

Return Value

Nonzero if successful; otherwise zero.

Parameters

nCol

Index of the column whose attributes are to be retrieved.

pColumn

Address of anLVCOLUMN structure that specifies the information to retrieve and receives information about the column. The mask member specifies which column attributes to retrieve. If the mask member specifies the LVCF_TEXT value, the pszText member must contain the address of the buffer that receives the item text and the cchTextMax member must specify the size of the buffer.

bzpscu 2003-08-25
  • 打赏
  • 举报
回复
我有试过,我可以取到column呀!好象LV_COLUMN和LVCOLUMN没什么区别吧,可能是你指定的buffer太小了,或者你没有设定LVCOLUMN的cchTextMax数据,或者是你的列号不对,我不知道你取到的是什么数据,但我在我的测试程序里面是取到了的。不知道其他人 运行上面代码的结果是否成功?try again ......
bmon_xyz 2003-08-24
  • 打赏
  • 举报
回复
用LVCOLUMN,还要注意先分配一段内存给pszText,否则函数返回地址会被覆盖,程序会跑飞。
lazycat818 2003-08-22
  • 打赏
  • 举报
回复
将bzpscu(满天星)的代码中LV_COLUMN改成LVCOLUMN看看。
bzpscu 2003-08-22
  • 打赏
  • 举报
回复
要设定pszText和cchTextMax
bzpscu 2003-08-22
  • 打赏
  • 举报
回复
char pszColumnText[100];
LV_COLUMN lvc ;
CListCtrl *pListCtrl = (CListCtrl *)GetDlgItem(IDC_LIST1);

lvc.mask = LVCF_TEXT ;
lvc.pszText = pszColumnText;
lvc.cchTextMax = 100;
pListCtrl->GetColumn( 1, &lvc);
AfxMessageBox( pszColumnText );
honglunxu 2003-08-22
  • 打赏
  • 举报
回复
试一下 GetHeaderCtrl( )->GetItem()这个操作
参数参考msdn
南风1 2003-08-22
  • 打赏
  • 举报
回复
有谁知道的,帮帮忙啊
flinming 2003-08-22
  • 打赏
  • 举报
回复
我也试过好多次得不到标题,但是可以设置标题!
南风1 2003-08-22
  • 打赏
  • 举报
回复
楼上这位好像没有这个函数吧
zyzyandzyzy 2003-08-22
  • 打赏
  • 举报
回复
对了,那个控件支持运行的时候输入吗,就像editbox那样
南风1 2003-08-22
  • 打赏
  • 举报
回复
大侠帮帮忙啊
南风1 2003-08-22
  • 打赏
  • 举报
回复
不行的楼上这位,你自己没试过吗?
lxwde 2003-08-21
  • 打赏
  • 举报
回复
getcolumntext
akiko 2003-08-21
  • 打赏
  • 举报
回复
LV_COLUMN lc={LVCF_TEXT};
BOOL b=m_l.GetColumn(n,&lc);

16,470

社区成员

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

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

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