GetWindowText和SetWindowTextW以及SetWindowText
时间:2011-11-28
来源:互联网
代码如下:
void CTestDlg::OnClickedBtnSum()
{
// TODO: Add your control notification handler code here
int num1,num2,num3;
char ch1[10],ch2[10],ch3[10];
GetDlgItem(IDC_EDIT1)->GetWindowText(ch1,10);
问题一:“->”处提示错误,信息如下,
1 IntelliSense: no instance of overloaded function "CWnd::GetWindowTextW" matches the argument list c:\users\administrator.pc-20110905onbv\desktop\demo\vc\dialog\mybole\mybole\testdlg.cpp 102 23 Mybole
“10”处提示错误,信息如下:
2 IntelliSense: too many arguments in function call c:\users\administrator.pc-20110905onbv\desktop\demo\vc\dialog\mybole\mybole\testdlg.cpp 102 43 Mybole
GetDlgItem(IDC_EDIT2)->GetWindowText(ch2,10);
num1=atoi(ch1);
num2=atoi(ch2);
num3=atoi(ch3);
itoa(num3,ch3,10);
GetDlgItem(IDC_EDIT3)->SetWindowText(ch3);
问题二:“ch3”处提示错误,信息如下:
5 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPCTSTR" c:\users\administrator.pc-20110905onbv\desktop\demo\vc\dialog\mybole\mybole\testdlg.cpp 108 39 Mybole
如果将“ch3”改为“_T(ch3)”,则会提示错误:
5 IntelliSense: identifier "Lch3" is undefined c:\users\administrator.pc-20110905onbv\desktop\demo\vc\dialog\mybole\mybole\testdlg.cpp 108 39 Mybole
这是怎么回事,应该怎样修改???
}
问题三:VS2010智能提示方法“SetWindowTextW”而不是“GetWindowText”,为什么???两者之间有什么样的差别呢???
void CTestDlg::OnClickedBtnSum()
{
// TODO: Add your control notification handler code here
int num1,num2,num3;
char ch1[10],ch2[10],ch3[10];
GetDlgItem(IDC_EDIT1)->GetWindowText(ch1,10);
问题一:“->”处提示错误,信息如下,
1 IntelliSense: no instance of overloaded function "CWnd::GetWindowTextW" matches the argument list c:\users\administrator.pc-20110905onbv\desktop\demo\vc\dialog\mybole\mybole\testdlg.cpp 102 23 Mybole
“10”处提示错误,信息如下:
2 IntelliSense: too many arguments in function call c:\users\administrator.pc-20110905onbv\desktop\demo\vc\dialog\mybole\mybole\testdlg.cpp 102 43 Mybole
GetDlgItem(IDC_EDIT2)->GetWindowText(ch2,10);
num1=atoi(ch1);
num2=atoi(ch2);
num3=atoi(ch3);
itoa(num3,ch3,10);
GetDlgItem(IDC_EDIT3)->SetWindowText(ch3);
问题二:“ch3”处提示错误,信息如下:
5 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPCTSTR" c:\users\administrator.pc-20110905onbv\desktop\demo\vc\dialog\mybole\mybole\testdlg.cpp 108 39 Mybole
如果将“ch3”改为“_T(ch3)”,则会提示错误:
5 IntelliSense: identifier "Lch3" is undefined c:\users\administrator.pc-20110905onbv\desktop\demo\vc\dialog\mybole\mybole\testdlg.cpp 108 39 Mybole
这是怎么回事,应该怎样修改???
}
问题三:VS2010智能提示方法“SetWindowTextW”而不是“GetWindowText”,为什么???两者之间有什么样的差别呢???
作者: starryplayer 发布时间: 2011-11-28
把你的char换成TCHAR
作者: VisualEleven 发布时间: 2011-11-28
下面的atoi()这些函数也需要修改_ttoi();
作者: VisualEleven 发布时间: 2011-11-28
你F12找一下SetWindowText的定义应该会发现其实它是根据工程所用字符集来调用SetWindowTextW或SetWindowTextA,而xp以上系统内部只有SetWindowTextW一个函数,SetWindowTextA也只是把参数转换后再调用SetWindowTextW而已
作者: paulcxz 发布时间: 2011-11-28
你看你的编译环境是什么
多字节,还是Unicode。。
多字节,还是Unicode。。
作者: shen_wei 发布时间: 2011-11-28
C/C++ code
int num1,num2,num3; TCHAR ch1[10],ch2[10],ch3[10]; GetDlgItem(IDC_EDIT1)->GetWindowText(ch1,10); GetDlgItem(IDC_EDIT2)->GetWindowText(ch2,10); num1=_wtoi(ch1); num2=_wtoi(ch2); num3=_wtoi(ch3); _itow(num3,ch3,10); GetDlgItem(IDC_EDIT3)->SetWindowText(ch3);
作者: wangweixu520 发布时间: 2011-11-28
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28