有如下例子代码一段
BEGIN_DDX_MAP(CMainDlg)
DDX_CONTROL(IDC_EDIT, m_wndEdit)
DDX_TEXT(IDC_EDIT, m_sEditContents)
DDX_INT(IDC_EDIT, m_nEditNumber)
END_DDX_MAP()
也就是《MFC程序员的WTL指南》中的一段
有一个问题:DDX_TEXT这一句会报错说不能把m_sEditContents这个CString转换成char*
网上找到了答案
这兄台叫Ruben
>My problem is:
>I am trying to do a Dialog application,
>but when I've tried to use CString with DDX_TEXT macro I've had
>problems and it didn't accept this TYPE of variable.
>
>Anybody knows why DDX_TEXT hasn´t accepted this TYPE of variable?
>
>It gives me a error message like this:
>
>error C2664: 'int __thiscall
>WTL::CWinDataExchangeCMainDlg>::DDX_Text(unsigned int,char
>*,int,int,int,int)' : cannot convert
>parameter 2 from 'class WTL::CString' to 'char *'
>No user-defined-conversion operator available that can perform this
>conversion, or the operator cannot be called
>
>Anybody knows how can I solve this problem?
>
>Thanks in advances
答案是
hi Ruben,
try including before including in your stdafx.h fileor
your app's .cpp file.
在书中,是在stdafx.h中加入了atlddx.h,再在里面加上atlmisc.h就行了
清单如下
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__4B9E2575_63C6_4F0D_BBA2_6E5B6F236611__INCLUDED_)
#define AFX_STDAFX_H__4B9E2575_63C6_4F0D_BBA2_6E5B6F236611__INCLUDED_
// Change these values to use different versions
#define WINVER 0x0400
//#define _WIN32_WINNT 0x0400
#define _WIN32_IE 0x0400
#define _RICHEDIT_VER 0x0100
#include
#include
extern CAppModule _Module;
#include
#include
#include
#include
#include
#include
#include
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__4B9E2575_63C6_4F0D_BBA2_6E5B6F236611__INCLUDED_)
最开始还有一个CPoint类认不出来,这是另外一个问题了,不过现在已经解决,不知道怎么解决的,难道与安装SDK有关?
当时总是提示.sbr文件找不着,网上的办法是删掉.ncb文件,暂时不懂有什么关系,不过做了似乎也没有效果。
WTL学习(2)
最新推荐文章于 2019-11-11 15:27:04 发布