读书人

一个字符窜资源的有关问题

发布时间: 2012-01-28 22:06:13 作者: rapoo

一个字符窜资源的问题
在一个.h的文件中。这么定义的

#ifdef _CADCITY
#define STRING_MSGBOX_CAPTION_T("CADCity-FILE")
#else
#define STRING_MSGBOX_CAPTION_T("D-COSMOS Light")
#ENDIF

现在要求的是把("CADCity-FILE")和("D-COSMOS Light")直接写在string table里面。这样方便直接修改,

有个问题,我怎么把字符窜资源的东西拿出来放进去??

刚才在.H里面这么做的
cstring strtitle;
cstring strtitle1;
strtitle.loadstring(id_file);
strtitle1.loadstring(id_light);

#ifdef _CADCITY
#define STRING_MSGBOX_CAPTION_T(str)
#else
#define STRING_MSGBOX_CAPTION_T(str1)
#ENDIF

编译没通过,
error C2143: syntax error : missing ';' before '.'
error C2501: 'strTitle' : missing storage-class or type specifiers
see declaration of 'strTitle'

HOW DO IT??




[解决办法]
可以这样

#define STRING_MSGBOX_CAPTION GetStr();

inline CString GetStr()
{
CString str;
#ifdef _CADCITY
str.LoadString(ID_STR1);
#else
str.LoadString(ID_STR2);
#endif
return str;
}

读书人网 >VC/MFC

热点推荐