问题描述
- 跪求大神帮忙看下代码,错了不晓得怎么改哦
-
switch (uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf(_T(szChar),_T( "char code is %d"), wParam);错误 1 error C2065: “LszChar”: 未声明的标识符
IntelliSense: "const wchar_t *" 类型的实参与 "const char *" 类型的形参不兼容
MessageBox(hwnd, _T(szChar), _T("XX虐编程"), MB_OKCANCEL); break; case WM_LBUTTONDOWN: MessageBox(hwnd, TEXT("点了"), TEXT("编程反被XX虐"), MB_OKCANCEL); HDC hdc; hdc = GetDC(hwnd); TextOut(hdc, 50, 50, TEXT("编程反抗了"), strlen(TEXT("编程反抗了"))); ReleaseDC(hwnd, hdc); break; case WM_PAINT: HDC hDc; PAINTSTRUCT ps; hDc = BeginPaint(hwnd, &ps); TextOut(hDc, 50, 50, TEXT("XX还是把它虐了"), strlen(TEXT("XX还是把它虐了")));
错误 3 error C2664: “size_t strlen(const char *)”: 无法将参数 1 从“const wchar_t [6]”转换为“const char *”
错误 4 error C2660: “TextOutW”: 函数不接受 4 个参数
EndPaint(hwnd, &ps); break; case WM_CLOSE: if (IDYES == MessageBox(hwnd, TEXT("编程over啦?"), TEXT("XX虐编程"), MB_YESNO)) DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } 错误提示: 错误 1 error C2065: “LszChar”: 未声明的标识符
解决方案
项目属性>配置属性>常规>字符集>使用多字节字符集
时间: 2024-11-03 00:42:48