请大家看看我这个程序错在哪里!
#include <windows.h>#include <stdio.h>
LRESULT CALLBACK wintc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nShowCmd
)
{
WNDCLASS wc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);//背景颜色
wc.hCursor=LoadCursor(NULL,IDC_CROSS);//光标
wc.hInstance=hInstance;//实例号
wc.hIcon=LoadCursor(NULL,IDI_ERROR);//图标
wc.lpszMenuName=NULL;
wc.lpszClassName=(LPCTSTR)"TQB";
wc.lpfnWndProc=wintc;
wc.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);//注册一个窗口
//=======创建一个窗口==============//
HWND hwnd;
hwnd=CreateWindow((LPCWSTR)"TQB",(LPCWSTR)"haha",WS_OVERLAPPEDWINDOW,0,0,600,500,NULL,NULL,hInstance,NULL);
//======显示一个窗口==============//
ShowWindow( hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))//消息循环
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK wintc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch (uMsg)
{
case WM_CHAR:
char a[20];
sprintf(a,"char is %d",wParam);
MessageBox(hwnd,(LPCWSTR)a,(LPCWSTR)"haha",0);
break;
case WM_LBUTTONDOWN:
break;
case WM_PAINT:
break;
case WM_CLOSE:
break;
case WM_DESTROY:
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
小弟初学VC,看了书后自己练习,但是在写后编译就是通过不,我用的是VS2005
出错原因:
>------ 已启动生成: 项目: lession1, 配置: Debug Win32 ------
1>正在编译...
1>winmain.cpp
1>d:\workspace\lession1\winmain.cpp(23) : error C2731: “WinMain”: 无法重载函数
1> d:\workspace\lession1\winmain.cpp(17) : 参见“WinMain”的声明
1>生成日志保存在“file://d:\workspace\lession1\lession1\Debug\BuildLog.htm”
1>lession1 - 1 个错误,0 个警告
========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========
各位兄弟姐妹,那个告诉我一下,为什么WinMain会无法重载?