新手用MFC求教,在咋们CSDN上搜到一个程序刚好我要用,收拾了一堆出错后剩下这个求教。

{WM_NULL,"WM_NULL"},
{WM_CREATE,"WM_CREATE"},
{WM_DESTROY,"WM_DESTROY"},
{WM_MOVE,"WM_MOVE"},
{WM_SIZE,"WM_SIZE"},
{WM_ACTIVATE,"WM_ACTIVATE"},
{WM_SETFOCUS,"WM_SETFOCUS"},
{WM_KILLFOCUS,"WM_KILLFOCUS"},
{WM_ENABLE,"WM_ENABLE"},
{WM_SETREDRAW,"WM_SETREDRAW"},
{WM_SETTEXT,"WM_SETTEXT"},
{WM_GETTEXT,"WM_GETTEXT"},
{WM_GETTEXTLENGTH,"WM_GETTEXTLENGTH"},
{WM_PAINT,"WM_PAINT"},
{WM_CLOSE,"WM_CLOSE"},
{WM_QUERYENDSESSION,"WM_QUERYENDSESSION"},
{WM_QUIT,"WM_QUIT"},
后半部分全是波浪线
出错提示:
1>e:\pjb\messagetip\messagetip\stdafx.h(71): error C2440: “初始化”: 无法从“const char [8]”转换为“LPCTSTR”
1> 与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
1>e:\pjb\messagetip\messagetip\stdafx.h(72): error C2440: “初始化”: 无法从“const char [10]”转换为“LPCTSTR”
1> 与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
1>e:\pjb\messagetip\messagetip\stdafx.h(73): error C2440: “初始化”: 无法从“const char [11]”转换为“LPCTSTR”
1> 与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
1>e:\pjb\messagetip\messagetip\stdafx.h(74): error C2440: “初始化”: 无法从“const char [8]”转换为“LPCTSTR”

mfc

4个回答

也可以在工程属性里禁用unicode

类型不符,LPCTSTR是指宽字符串,用字符串初始化时应强制转换,一般用_T(),如CString str=_T("hello world");

先看结构体的定义吧,保证定义与变量赋值一致。如果是unicode,也字符串需要使用TEXT,_T或者L

这个里面所有的字符串都要用_T()包起来 才能兼容宽字符及 mfc过时了 建议换吧

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问