窗口问题(回答了给100分)
程序我是照书编的。。。运行时有17个错误,请帮忙解决下。#include<Windows.h>
long FAR PASCAL WndProc(HWND,WORD,WORD,LONG);
int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance,LPSTR lpszCmdParam,int nComShow)
{
HWND hwnd;
MSG msg;
if(!hPrevInstance)
{
wc.style=NULL;
wc.lpfnWndProc=WndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackgroud=GetStockObject(WHITE_BRUSH);
wc.lpszMenuName=NULL;
wc.lpszClassName="Class_W1";
RegisterClass(&wc);
}
hwnd=GreateWindow(
"Class_W1,
"Hello,World-Windows style",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hwnd,nComdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,NULL,NULL))
DispatchMessage(&msg);
return msg,wParam;
}
long FAR PASCAL WndProc(HWND hwnd,WORD message,WORD wParam,LONG lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hwnd,message,wParam,lParam));
return NULL;
}
}
E:\C++程序\基础\窗口.cpp(4) : error C2731: 'WinMain' : function cannot be overloaded
E:\C++程序\基础\窗口.cpp(3) : see declaration of 'WinMain'
E:\C++程序\基础\窗口.cpp(9) : error C2065: 'wc' : undeclared identifier
E:\C++程序\基础\窗口.cpp(9) : error C2228: left of '.style' must have class/struct/union type
E:\C++程序\基础\窗口.cpp(10) : error C2228: left of '.lpfnWndProc' must have class/struct/union type
E:\C++程序\基础\窗口.cpp(11) : error C2228: left of '.cbClsExtra' must have class/struct/union type
E:\C++程序\基础\窗口.cpp(12) : error C2228: left of '.cbWndExtra' must have class/struct/union type
E:\C++程序\基础\窗口.cpp(13) : error C2228: left of '.hInstance' must have class/struct/union type
E:\C++程序\基础\窗口.cpp(14) : error C2228: left of '.hIcon' must have class/struct/union type
E:\C++程序\基础\窗口.cpp(15) : error C2228: left of '.hCursor' must have class/struct/union type
E:\C++程序\基础\窗口.cpp(16) : error C2228: left of '.hbrBackgroud' must have class/struct/union type
E:\C++程序\基础\窗口.cpp(17) : error C2228: left of '.lpszMenuName' must have class/struct/union type
E:\C++程序\基础\窗口.cpp(18) : error C2228: left of '.lpszClassName' must have class/struct/union type
E:\C++程序\基础\窗口.cpp(21) : error C2065: 'GreateWindow' : undeclared identifier
E:\C++程序\基础\窗口.cpp(22) : error C2001: newline in constant
E:\C++程序\基础\窗口.cpp(33) : error C2440: '=' : cannot convert from 'int' to 'struct HWND__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
E:\C++程序\基础\窗口.cpp(34) : error C2065: 'nComdShow' : undeclared identifier
E:\C++程序\基础\窗口.cpp(38) : error C2065: 'wParam' : undeclared identifier
Error executing cl.exe.
[ 本帖最后由 XIAO荣 于 2009-8-22 10:50 编辑 ]