我用ACTIVE CONTROL TEST CONTAINER测试的,当我用INVOKE时(我事先设了断点)跟踪进去时如我输入的是“我要做一个程序员”变成了“{"b亯ZP"}”了,输入函数为: void CAnalysisCtrl::SetString(LPCTSTR InString) { midString=InString; ……………………
C:\Documents and Settings\王\Analysis\AnalysisCtl.cpp(529) : error C2664: 'strcpy' : cannot convert parameter 1 from 'class CString' to 'char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called C:\Documents and Settings\王\Analysis\AnalysisCtl.cpp(530) : error C2664: 'strcpy' : cannot convert parameter 1 from 'class CString' to 'char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called AnalysisPpg.cpp Generating Code... Error executing cl.exe.Analysis.ocx - 2 error(s), 0 warning(s)
void CAnalysisCtrl::SetString(LPCTSTR InString)
{
midString=InString;
……………………
void CAnalysisCtrl::SetString(LPCTSTR InString)
{
midString="";
midString=InString;
还是不行
{"b/f?梍剉梍"}
可以正确输出。
没有BSTR只有BSTR FAR *不知怎么用?
throw( CMemoryException );midString = CString(InString, strlen(InString));
strcpy()
MIDSTRING只剩了一个字符了。
是不是我的VC++出问题了。
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Documents and Settings\王\Analysis\AnalysisCtl.cpp(530) : error C2664: 'strcpy' : cannot convert parameter 1 from 'class CString' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
AnalysisPpg.cpp
Generating Code...
Error executing cl.exe.Analysis.ocx - 2 error(s), 0 warning(s)
我想将CONST SHORT*转换成CONST CHAR*再转换成CSTRING是不是可以。
因为我的8个汉字成了8个字母(勉强可以这么说),是不是每个汉字的高字节编码被覆盖了?
先要将InString转换成字符串才可以。
处理方法一:
如果你的ocx也是为其它vc应用程序服务,那么,建议debug和release版本都用非UNICODE方式编译,问题应该能解决,而且调用界面也简单。处理方法二:
如果ocx是用UNICODE方式编译,那么用MultiByteToWideChar将char *类型的东西转换为wchar_t *类型的东西,至于宽字符和单字符串转换,有很多方法,用WideCharToMultiByte是最直接的方法。wchar_t*型字符串现在是c语言的标准,wcscat系列runtime函数一定要过关,否则,你很难在将来的windows上有所作为了。