| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1939 人关注过本帖
标题:关于函数 InsertColumn第二个参数编译不通过的问题
只看楼主 加入收藏
panfeng415
Rank: 1
等 级:新手上路
帖 子:13
专家分:4
注 册:2015-2-7
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:2 
关于函数 InsertColumn第二个参数编译不通过的问题
CListCtrl*pList=(CListCtrl*)GetDlgItem(IDC_LIST);
    pList-> InsertColumn(0,"工号",LVCFMT_LEFT,120);
    pList-> InsertColumn(1,"员工",LVCFMT_LEFT,160);
    pList-> InsertColumn(2,"工资",LVCFMT_LEFT,160);
产生编译错误error C2664: 'int CListCtrl::InsertColumn(int,LPCTSTR,int,int,int)' : cannot convert parameter 2 from 'const char [5]' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

函数原型:
int InsertColumn(int nCol, const LVCOLUMN* pColumn);
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1);

nCol表示要插入列的列号。
pColumn 为新建列属性的LVCOLUMN结构的地址。

对于第二种函数重载,参数lpszcolumnHeading 为列标题的字符串的地址,所以可以使用一个字符串,比如 "姓名"。
nFormat 指定列对齐方式的整数,缺省值是左对齐。它可以为下列值之一:LVCFMT_LEFT,LVCFMT_RIGHT或LVCFMT_CENTER。
nWidth 以像素为单位的列宽。缺省值为-1,表示没有设置列宽。
nSubItem 与列相关联的子项的索引。缺省值为-1,表示没有子项与列相关。
什么原因呢?visual c++ 6.0 可以编译通过,有没有什么办法可以通过 visual studio 2010的编译?
搜索更多相关主题的帖子: conversion convert cannot 
2015-04-08 16:12
天使梦魔
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:37
帖 子:564
专家分:2754
注 册:2007-8-29
收藏
得分:10 
cannot convert parameter 2 from 'const char [5]' to 'LPCTSTR'
不能把标准字符转换成宽字符,在每个中文引号的前面加上大写的L
2015-04-08 16:26
panfeng415
Rank: 1
等 级:新手上路
帖 子:13
专家分:4
注 册:2015-2-7
收藏
得分:0 
回复 2楼 天使梦魔
编译是通过了可是我要的分组怎么不粗线
图片附件: 游客没有浏览图片的权限,请 登录注册
2015-04-08 19:17
快速回复:关于函数 InsertColumn第二个参数编译不通过的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015501 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved