CFont和CString出现的问题

zss1103 2006-07-12 11:50:27
CFont titleFont;
titleFont.CreateFont(28, 0, 0, 0, 700, FALSE, FALSE, 0,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN,"Arial");

error C2664: 'CFont::CreateFontW' : cannot convert parameter 14 from 'const char [6]' to 'LPCTSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

CString tickLabel;
tickLabel.Format("%d", tickRange);

error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *'
with
[
BaseType=wchar_t,
StringTraits=StrTraitMFC_DLL<wchar_t>
]
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

以上代码在vs6.0中编译通过,在vs2005中出错,那位高人知道这是怎么回事?应该怎样修改?谢谢
...全文
253 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wanilyer 2006-07-12
  • 打赏
  • 举报
回复
上面弄错了,第二个问题不知道
wanilyer 2006-07-12
  • 打赏
  • 举报
回复
第二个问题 把%(中文状态下的)改成%(英文状态下的)
wanilyer 2006-07-12
  • 打赏
  • 举报
回复
第一个问题可以这样解决 (LPCTSTR)(CString)(char*)("Arial")
Xman2006 2006-07-12
  • 打赏
  • 举报
回复
宽字符的问题吧。wchar_t是宽字符,unicode的,char [3]是ASCII的字符串,你用TEXT("your string")试试 .
hijack 2006-07-12
  • 打赏
  • 举报
回复
UNICODE问题
zss1103 2006-07-12
  • 打赏
  • 举报
回复
谢谢
EddieCai 2006-07-12
  • 打赏
  • 举报
回复
第一个是
titleFont.CreateFont(28, 0, 0, 0, 700, FALSE, FALSE, 0,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN,_T("Arial"));
EddieCai 2006-07-12
  • 打赏
  • 举报
回复
CString tickLabel;
tickLabel.Format(_T("%d"), tickRange);
zss1103 2006-07-12
  • 打赏
  • 举报
回复
Xman2006() 你能够说的详细一点?
zss1103 2006-07-12
  • 打赏
  • 举报
回复
wanilyer(缘随影去)
第一个问题可以这样解决 (LPCTSTR)(CString)(char*)("Arial")
第一个问题现在不报错了

有关CString的问题还是没有解决,那位高人能给指点一下阿

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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