Win32app问题,懂得的都进来指点吧。
#include<windows.h>#include<stdio.h>
#include<Winuser.h>
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nShowCmd)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=NULL;
wndcls.hIcon=NULL;
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WindowProc;
wndcls.lpszClassName="weixin2010";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_DBLCLKS;
RegisterClass(&wndcls);
HWND hwnd;
hwnd=CreateWindow("weixin2010","自学窗口",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0,"窗口培训",strlen("窗口培训"));
EndPaint(hwnd,&ps);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
break;
}
return 0;
}
这是提示错的地方。WinMain无法重载函数这里是什么意思呢!一般要什么样的情况下能使WinMain重载函数呢?还有如何才能将那些错误的参数 转换为“LPCWSTR”的呢!我在MSDN上查了下但还是搞不懂!!!
c:\documents and settings\administrator\桌面\c\win32app\win32app\gt_helloworldwin32.cpp(15) : error C2731: “WinMain”: 无法重载函数
c:\documents and settings\administrator\桌面\c\win32app\win32app\gt_helloworldwin32.cpp(10) : 参见“WinMain”的声明
c:\documents and settings\administrator\桌面\c\win32app\win32app\gt_helloworldwin32.cpp(24) : error C2440: “=”: 无法从“const char [10]”转换为“LPCWSTR”
与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
c:\documents and settings\administrator\桌面\c\win32app\win32app\gt_helloworldwin32.cpp(31) : error C2664: “CreateWindowExW”: 不能将参数 2 从“const char [10]”转换为“LPCWSTR”
与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
c:\documents and settings\administrator\桌面\c\win32app\win32app\gt_helloworldwin32.cpp(57) : error C2664: “TextOutW”: 不能将参数 4 从“const char [9]”转换为“LPCWSTR”
与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
生成日志保存在“file://c:\Documents and Settings\Administrator\桌面\C\Win32app\Win32app\Debug\BuildLog.htm”
Win32app - 4 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========