新微赢技术网
标题:
请教高手,我是初学者,问题出在哪,谢谢啦!
[打印本页]
作者:
老子xin坏
时间:
2009-11-4 00:54
标题:
请教高手,我是初学者,问题出在哪,谢谢啦!
# include <windows.h>
# include <stdio.h>
LRESULT CALLBACK WinSunProc(
HWND hwnd,
UINT uMag,
WPARAM wParam,
LPARAM lParam
)
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackgroud=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="radio983";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegristerCLASS(&wndcls);
HWND Hwnd;
Hwnd=CreateWindow("radio983","抄袭编程",WS_OVERLAPPEDWINDOW,
0,0,800,600,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 WinSunProc(
HWND hwnd,
UINT uMag,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMag)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d,wParam);
MessageBox(hwnd,szChar,"radio983",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse clicked","radio983",0);
HDC=hdc;
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 WN_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真得结束?","radio983",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WN_DESTORY:
PostQuitMessage(0);
break;
default:
return DfeWindowProc(hwnd,uMag,wParam,lParam);
}
return 0;
}
————————————————————————————————————————————
--------------------Configuration: winmain - Win32 Debug--------------------
Compiling...
winmain.cpp
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(12) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(12) : error C2143: syntax error : missing ';' before '__stdcall'
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(22) : error C2039: 'hbrBackgroud' : is not a member of 'tagWNDCLASSA'
d:\vc98\include\winuser.h(1184) : see declaration of 'tagWNDCLASSA'
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(30) : error C2065: 'RegristerCLASS' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(58) : error C2001: newline in constant
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(59) : error C2146: syntax error : missing ')' before identifier 'MessageBoxA'
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(63) : error C2513: 'struct HDC__ *' : no variable declared before '='
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(63) : error C2065: 'hdc' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(65) : error C2065: 'ReleaseDc' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(68) : error C2513: 'struct HDC__ *' : no variable declared before '='
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(68) : error C2065: 'hDC' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(70) : error C2065: 'hDc' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(70) : error C2440: '=' : cannot convert from 'struct HDC__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(74) : error C2065: 'WN_CLOSE' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(74) : error C2051: case expression not constant
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(80) : error C2065: 'WN_DESTORY' : undeclared identifier
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(80) : error C2051: case expression not constant
D:\Program Files\MSDev98\MyProjects\lesson1\winmain.cpp(84) : error C2065: 'DfeWindowProc' : undeclared identifier
执行 cl.exe 时出错.
winmain.exe - 1 error(s), 0 warning(s)
作者:
兮哩糊涂の斗
时间:
2009-11-4 00:54
# include <windows.h>
# include <stdio.h>
LRESULT CALLBACK WinSunProc(
HWND hwnd,
UINT uMag,
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="radio983";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls);//你单词错了
HWND Hwnd;
Hwnd=CreateWindow("radio983","抄袭编程",WS_OVERLAPPEDWINDOW,
0,0,800,600,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 WinSunProc(
HWND hwnd,
UINT uMag,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMag)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d",wParam);//掉了"
MessageBox(hwnd,szChar,"radio983",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse clicked","radio983",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,"是否真得结束?","radio983",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY :
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMag,wParam,lParam);
}
return 0;
}
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2