求助:c++编译的一个问题
源程序:#include <windows.h>
#include <stdio.h>
int WINAPI winmain{
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
}
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockobject(black_brush);
wndcls.hcursor=loadcursor(null,idc_cross);
wndcls.hicon=loadicon(null,idi_error);
wndcls.hinstance=hinstance;
wndcls.lpfnwndproc=winsunproc;
wndcls.lpszclassname="Weixin2003";
wndcls.lpszmenuname=null;
wndcls.style=|cs_hredraw | cs_verdraw;
registerclass(&wndcls);
hwnd hwnd;
hwnd=createwindow("Weixin2003","北京维新科学技术培训中心",ws overlappedwindow,
0,0,600,400,NULL,NULL,hInstance,NULL);
showwindow(hwnd,sw_showhormal);
updatewindow(hwnd);
msg msg;
while(getmessage(&msg,null,0,0))
{
translatemessage(&msg);
dispatchmessage(&msg);
}
return 0;
}
LRESULT CALLBACK WInSunProc(
HWND hwnd,
UINT umsg,
wpapam wparam,
lparam lparam
)
{
switch(umsg)
{
case wm_char:
char szChar[20];
sprintf(szChar,"char is %d ",wparam);
messageBox(hwnd,szchar,"weixin",0);
break;
case wm_lbuttondown:
messageBox(hwnd,"mouse clicked","weixin",0);
HDC hdc;
hdc=GetDC(hdc ,0,50,"计算机",strlen("计算机"));
ReleaseDc(hwnd,hdc);
break;
case wm_paint:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
Textout(hDc,0,0,"维新培训",strlen("维新培训");
EndPaint(hwnd,&ps);
break;
case WM_Destroy:
PostQuitmessage(0);
break;
default:
return defwindowproc(hwnd,umsg,wparam,lparam);
}
return 0;
}
编译出错信息:
--------------------Configuration: winmain - Win32 Debug--------------------
Compiling...
winmain.cpp
d:\work\study\c++\lesson1\winmain\winmain.cpp(4) : warning C4229: anachronism used : modifiers on data are ignored
d:\work\study\c++\lesson1\winmain\winmain.cpp(4) : error C2239: unexpected token '{' following declaration of 'winmain'
d:\work\study\c++\lesson1\winmain\winmain.cpp(10) : error C2447: missing function header (old-style formal list?)
d:\work\study\c++\lesson1\winmain\winmain.cpp(43) : error C2061: syntax error : identifier 'wpapam'
d:\work\study\c++\lesson1\winmain\winmain.cpp(49) : error C2065: 'wm_char' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(49) : error C2051: case expression not constant
d:\work\study\c++\lesson1\winmain\winmain.cpp(51) : error C2065: 'wparam' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(52) : error C2065: 'messageBox' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(52) : error C2065: 'szchar' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(54) : error C2065: 'wm_lbuttondown' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(54) : error C2051: case expression not constant
d:\work\study\c++\lesson1\winmain\winmain.cpp(57) : error C2660: 'GetDC' : function does not take 5 parameters
d:\work\study\c++\lesson1\winmain\winmain.cpp(58) : error C2065: 'ReleaseDc' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(60) : error C2065: 'wm_paint' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(60) : error C2051: case expression not constant
d:\work\study\c++\lesson1\winmain\winmain.cpp(64) : error C2065: 'Textout' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(64) : error C2065: 'hDc' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(64) : error C2143: syntax error : missing ')' before ';'
d:\work\study\c++\lesson1\winmain\winmain.cpp(67) : error C2065: 'WM_Destroy' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(67) : error C2051: case expression not constant
d:\work\study\c++\lesson1\winmain\winmain.cpp(68) : error C2065: 'PostQuitmessage' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(71) : error C2065: 'defwindowproc' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(71) : error C2065: 'lparam' : undeclared identifier
d:\work\study\c++\lesson1\winmain\winmain.cpp(72) : warning C4065: switch statement contains 'default' but no 'case' labels
执行 cl.exe 时出错.
winmain.obj - 1 error(s), 0 warning(s)