网上找到的方法均无法解决!
cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'
就是下面这个函数:
hWnd = CreateWindow("EDIT", _T("This window was created from main() and can get messages from the console below."),我使用L"ABC"或者_T("ABC")错误依旧。
我的是Console Application。默认使用Unicode的VC2005。#include <windows.h>
#include <stdio.h>DWORD WINAPI mainGUI( LPVOID lp)
{
HMODULE hInstance= 0;
hInstance = GetModuleHandle(NULL);
HWND hWnd; MSG msg;
hWnd = CreateWindow("EDIT", _T("This window was created from main() and can get messages from the console below."),
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
if (!hWnd) return (1);
*(HWND*)lp = hWnd;
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
while (GetMessage(&msg, NULL, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}int main(int argc, char* argv[])
{
DWORD ID; HWND hWindow;
char szOutput[64];
CreateThread(NULL,0,mainGUI, &hWindow, NULL,&ID);
printf("This console created the window above.\nType in the message you want to send to the window.\n\"quit\" to exit.\n\n");
while (true) {
scanf("%s", szOutput);
if (!strcmp(szOutput, "quit")) break;
SendMessage(hWindow,WM_SETTEXT, strlen(szOutput), (LPARAM)szOutput);
}
return 0;
}error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'
cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'
就是下面这个函数:
hWnd = CreateWindow("EDIT", _T("This window was created from main() and can get messages from the console below."),我使用L"ABC"或者_T("ABC")错误依旧。
我的是Console Application。默认使用Unicode的VC2005。#include <windows.h>
#include <stdio.h>DWORD WINAPI mainGUI( LPVOID lp)
{
HMODULE hInstance= 0;
hInstance = GetModuleHandle(NULL);
HWND hWnd; MSG msg;
hWnd = CreateWindow("EDIT", _T("This window was created from main() and can get messages from the console below."),
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
if (!hWnd) return (1);
*(HWND*)lp = hWnd;
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
while (GetMessage(&msg, NULL, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}int main(int argc, char* argv[])
{
DWORD ID; HWND hWindow;
char szOutput[64];
CreateThread(NULL,0,mainGUI, &hWindow, NULL,&ID);
printf("This console created the window above.\nType in the message you want to send to the window.\n\"quit\" to exit.\n\n");
while (true) {
scanf("%s", szOutput);
if (!strcmp(szOutput, "quit")) break;
SendMessage(hWindow,WM_SETTEXT, strlen(szOutput), (LPARAM)szOutput);
}
return 0;
}error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'
解决方案 »
- DrawPath()的GDI+ 原函数 有没有呢?字体处理
- vc++下opengl场景漫游怎样实现蹲和跳
- 请教,为何在OCX控件中,CDialog::Create()方法会失败?
- 控件Micosoft Toolbar Control 6.0怎么使用?
- ADO中的连接问题!在线等!请大家指点!
- error LNK2001,求助?
- 请求高手指点!
- 请高手指点一下,VC中用OleLoadPicture装载从网页中保存到内存中的图片时失败
- 请教:如何画带有单箭头,双箭头的线?急!
- variable type中cstring怎么弄成int啊
- 怎样可以改变GroupBox控件区域的背景颜色?
- 怎么让edit失去输入焦点
hWnd = CreateWindow(_T("EDIT"), _T("This window was created from main() and can get messages from the console below."),
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
可是:
cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'
为什么错误是parameter 2而不是parameter 1呢?
可是
HWND CreateWindow( LPCTSTR lpClassName,
LPCTSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
);
并不是一个宏阿?我查找了MSDN