我试图为一个旧的袖珍应用程序制作一个简单的程序。
希望它得到时间,并在我使用按钮时显示它。
通过下面的代码,我得到了两个编译器错误:
error C2664: 'SetWindowTextW' : cannot convert parameter 1 from 'int' to 'HWND' Line: 201
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR' Line: 233我试着去寻找,似乎是一个常见的误解,但我看不出一个适合的解释。
_strdate( dateStr);
SetWindowText(1003, dateStr);此外,还包括:
hwndLabel = CreateWindow("STATIC","Time",
WS_VISIBLE | WS_CHILD | SS_RIGHT,
10,200,75,35,hWnd,NULL,1003,NULL);编辑:
在Xearinox建议之后,我得到了三个新的错误。
这些:
error C2664: '_wstrdate' : cannot convert parameter 1 from 'char [9]' to 'wchar_t *' 199
error C2664: 'SetDlgItemTextW' : cannot convert parameter 3 from 'char [9]' to 'LPCWSTR' 201
error C2440: '=' : cannot convert from 'HWND' to 'int' 233如果从静态中删除(HMENU),则会得到最后一个错误:
error C2664: 'CreateWindowExW' : cannot convert parameter 10 from 'int' to 'HMENU' 233发布于 2013-08-14 14:22:35
SetWindowText的第一个参数是hwnd,而不是控制标识符。试试这个:
SetDlgItemTextW(hWnd, 1003, dateStr);将此用于检索日期:
WCHAR dateStr[256] = {0};
_wstrdate(dateStr);还对CreateWindow使用宽字符串参数:
hwndLabel = CreateWindowW(L"STATIC",L"Time",
WS_VISIBLE | WS_CHILD | SS_RIGHT,
10,200,75,35,hWnd, (HMENU)1003, NULL, NULL);https://stackoverflow.com/questions/18234187
复制相似问题