首页 新闻 会员 周边

error C2039: 'SetWindowTextA' : is not a member of 'CString'

0
悬赏园豆:20 [待解决问题]

C++新手,急求高手回答

一个简单的MFC对话框文件打开程序,代码如下:

CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"All File(*.TXT)|*.TXT||",AfxGetMainWnd());
 CString strPath,strText = "";
 if(dlg.DoModal() == IDOK)
 {
  strPath = dlg.GetFileName();
  m_OpenPath.SetWindowText(strPath);
  CFile file(strPath,CFile::modeRead);
  char read[10000];
  file.Read(read,10000);
  for(int i = 0;i < file.GetLength();i++)
  {
   strText += read[i];
  }
  file.Close();
  m_FileContent.SetWindowText(strText);
 }

QQseei的主页 QQseei | 初学一级 | 园豆:180
提问于:2011-07-15 11:50
< >
分享
所有回答(3)
1

m_OpenPath,m_FileContent的类型不对,不应该是CString类型

artwl | 园豆:16736 (专家六级) | 2011-07-15 11:59
可是我改成CStatic类型的时候可以编译通过,不过什么效果都没有,不能显示路径和文本内容
支持(0) 反对(0) QQseei | 园豆:180 (初学一级) | 2011-07-15 12:45
0

解决方法:项目属性—〉配置属性—〉常规—〉字符集—〉多字节字符集

wusuopuBUPT | 园豆:35 (初学一级) | 2011-12-21 15:18
0

m_OpenPath.SetWindowText(strPath);

从错误看,m_OpenPath 是你的一个CString成员变量,当然没这个成员函数。

你可能是想 dlg.SetWindowText(..)

调用这个函数至少你也是该从CWnd继承的东西。

hoodlum1980 | 园豆:559 (小虾三级) | 2012-06-07 17:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册