[求助]一个简单的VC语法,照抄的,但是不知道错在哪
#include <windows.h> #include <stdio.h>
LRESULT CALLBACK WinsunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lparam
)
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="weixin2008";
wndcls.lpszmenuname=null;
wndcls.style=cs_hredraw | cs_vredraw;
registerclass(&wndcls);
hwnd hwnd;
hwnd=createwindow("weixin2003","维新学习",ws_overlappedwindow,0.0,600,400,null,null,hinstance,null);
showwindow(hwnd,sw_shownormall);
updatewindow(hwnd);
msg msg;
while(getmessage(&msg,null,0,0))
{
Translatemessage(&msg);
dispatchmessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinsunProc(
HWND hwnd,
UINT uMsg,
WPARAM 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(hwnd);
TextOut(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_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的结束?","weixin",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefwindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
--------------------Configuration: O1 - Win32 Debug--------------------
Compiling...
o1.cpp
E:\VCe\O1\o1.cpp(11) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
E:\VCe\O1\o1.cpp(11) : error C2146: syntax error : missing ';' before identifier 'WinApi'
E:\VCe\O1\o1.cpp(11) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
O1.exe - 2 error(s), 1 warning(s)