最近在学 VC++
按书上写了个最简单的程序 ,当调用到zuche=RegisterClass(&wcApp);是返回零 提示不成功 ,用的编译器是VC++6.0英文版 请高手指点一下 谢谢
#include "windows.h"
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);//ROUTE DECLARE
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int);//ENTRY ROUTE DECLARE
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdline,int nCmdShow)
{
WNDCLASS wcApp; //define windows class
MSG msg; //define windows message
HWND hwnd;
bool zuche;
char *szAppName="Windows API Application";
char *szAppTitle="Windows API WINDOW ROUTE";
wcApp.style=CS_HREDRAW;
wcApp.lpfnWndProc=WndProc;
wcApp.cbClsExtra=0;
wcApp.cbWndExtra=0;
wcApp.hInstance=hInstance;
wcApp.hCursor=LoadCursor(NULL,IDC_ARROW);
wcApp.hbrBackground=(HBRUSH)COLOR_ACTIVEBORDER;
wcApp.lpszMenuName=NULL;
wcApp.lpszClassName="Windows API WINDOW ROUTE";
zuche=RegisterClass(&wcApp);
hwnd=CreateWindow(szAppName,szAppTitle,WS_OVERLAPPEDWINDOW,100,100,350,300,NULL,NULL,hInstance,NULL);
if(NULL==hwnd)
{
MessageBox(GetFocus(),NULL,"创建窗口失败",MB_OK|MB_ICONEXCLAMATION);
// return 0;
}
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)
{
char* msgCreate="收到WM_CREATE消息,建立窗口";
char* msgDestroy="收到WM_DESTROY消息,窗口关闭";
char* msgCaption="收到消息";
char* msgLBTN="鼠标左键按下,收到WM_LBUTTONDOWN消息";
switch(message)
{
case WM_CREATE:
MessageBox(GetFocus(),msgCreate,msgCaption,MB_OK|MB_ICONEXCLAMATION);
break;
case WM_LBUTTONDOWN:
MessageBox(GetFocus(),msgCreate,msgCaption,MB_OK|MB_ICONEXCLAMATION);
break;
case WM_DESTROY:
MessageBox(GetFocus(),msgCreate,msgCaption,MB_OK|MB_ICONEXCLAMATION);
break;
default:
return DefWindowProc(hWnd,message,wParam,lParam);
}
return FALSE;
}
请教窗口不能注册的问题