Q_O() 谢谢你!请看内容:
源程序:
//
# include <windows.h>
//# include <iostream.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
//
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInst,
LPSTR lpszCmdLine,
int nCmdShow)
{
HWND hwnd ;
MSG Msg;
WNDCLASS wndclass;
char lpszClassName[]="窗口";
char lpszTitle[]="My-windows";
//
wndclass.style=0;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI-APPLICATION);
wndclass.hCursor=loadCursor(NULL,IDC-ARROW);
wndclass.hbrBackground=GetstockObject(WHITE-BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=lpszClassName;
//
if(!RegisterClass(&wndclass))
{
MessageBeep(0);
return FALSE;
}
//
hwnd=CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
//
ShowWindow(hwnd,nCmdShow);
//
UpdateWindow(hwnd);
//
while(GetMessage(&Msg,NULL,0,0))
{
translateMessage(&Msg);
dispatchMessage(&Msg);
}
return Msg.wParam;
}
//
LRESULT CALLBACK WndProc( HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return(0);
}
编译结果:
-Configuration: ma1 - Win32 Debug--------------------
Compiling...
ma1.cpp
D:\软件2\vc++\excise\ma1.cpp(23) : error C2065: 'IDI' : undeclared identifier
D:\软件2\vc++\excise\ma1.cpp(23) : error C2065: 'APPLICATION' : undeclared identifier
D:\软件2\vc++\excise\ma1.cpp(23) : error C2664: 'LoadIconA' : cannot convert parameter 2 from 'int' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
D:\软件2\vc++\excise\ma1.cpp(24) : error C2065: 'loadCursor' : undeclared identifier
D:\软件2\vc++\excise\ma1.cpp(24) : error C2065: 'IDC' : undeclared identifier
D:\软件2\vc++\excise\ma1.cpp(24) : error C2065: 'ARROW' : undeclared identifier
D:\软件2\vc++\excise\ma1.cpp(24) : error C2440: '=' : cannot convert from 'int' to 'struct HICON__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
D:\软件2\vc++\excise\ma1.cpp(25) : error C2065: 'GetstockObject' : undeclared identifier
D:\软件2\vc++\excise\ma1.cpp(25) : error C2065: 'WHITE' : undeclared identifier
D:\软件2\vc++\excise\ma1.cpp(25) : error C2065: 'BRUSH' : undeclared identifier
D:\软件2\vc++\excise\ma1.cpp(25) : error C2440: '=' : cannot convert from 'int' to 'struct HBRUSH__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
D:\软件2\vc++\excise\ma1.cpp(53) : error C2065: 'translateMessage' : undeclared identifier
D:\软件2\vc++\excise\ma1.cpp(54) : error C2065: 'dispatchMessage' : undeclared identifier
Error executing cl.exe.
ma1.obj - 13 error(s), 0 warning(s)
问题点数:20、回复次数:4Top
1 楼Q_O()回复于 2002-04-27 21:02:26 得分 2
1: do u include resource.h?
2: loadIcon second param is a int type . u should
wndclass.hIcon = (HICON) LoadIcon(NULL,MAKEINTRESOURCE(IDI-APPLICATION));
treat cursor as same way
Top
2 楼feihong6(蓝天飞鸿)回复于 2002-04-30 07:20:38 得分 0
我另外的问题在0:54发布的,标题为:"急上加急!!!上班试验期第一天,出问题!请大哥哥帮忙!!!"
请大家想办法迅速解救!
:(
Top
3 楼feihong6(蓝天飞鸿)回复于 2002-04-30 07:26:57 得分 0
补充一句:上面的问题在DELPHI论坛中!Top
4 楼jyu1221(天同)回复于 2002-05-14 15:47:14 得分 18
我来拿分了Top




