首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

新手求教!该怎么解决

2012-06-24 
新手求教!代码好下:#include windows.hLRESULT CALLBACK Wndproc(HWND hWnd,UINT uMsgId,WPARAM wParam,

新手求教!
代码好下:

#include <windows.h>
LRESULT CALLBACK Wndproc(HWND hWnd,UINT uMsgId,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
static char thisAppName[]="welcome to vc++";
HWND hWnd;
MSG msg;
WNDCLASS wndclass;
wndclass.lpszClassName=thisAppName;
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=Wndproc;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadIcon(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
if (!RegisterClass(&wndclass))
{
MessageBox(NULL,"窗口注册失败!","出错提示",MB_OK);
return 0;
}

HWND CreateWindows(thisAppName,
thisAppName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if (hWnd==0)
{
return 0;
}
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while (GetStockObject(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

LRESULT CALLBACK Wndproc(HWND hWnd,UINT uMsgId,WPARAM wParam,LPARAM lParam)
{
switch(uMsgId)
{
case WM_CREATE:
return 0;
case WM_LBUTTONDOWN:
MessageBox(NULL,"HELLO,THE WORLD!","HELLO",MB_OK);
return O;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd,uMsgId,wParam,lParam);
}
}



编译报错如下:
--------------------Configuration: windows应用程序 - Win32 Debug--------------------
Compiling...
file01.cpp
D:\软件工程\windows应用程序\file01.cpp(35) : error C2078: too many initializers
D:\软件工程\windows应用程序\file01.cpp(42) : error C2660: 'GetStockObject' : function does not take 4 parameters
D:\软件工程\windows应用程序\file01.cpp(42) : fatal error C1903: unable to recover from previous error(s); stopping compilation
执行 cl.exe 时出错.

windows应用程序.exe - 1 error(s), 0 warning(s)




求高手指教,小弟多谢了!

[解决办法]
CreateWindow,不是CreateWindows

热点排行