[求助]人门的问题,请指点一下!
#include "stdafx.h"
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); //窗口函数说明
int APIENTRY WinMain(HINSTANCE hInstance, //主函数说明
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
char lpszClassName[] = "窗口";
char lpszTitle[] = "My_Wondows";
wndclass.style = 0; //窗口类型默认
wndclass.lpfnWndProc = WndProc; //窗口主力函数为 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);
// TOD Place code here.
return (0);
}
我是照搬书上的代码的,怎么还是出错了呢?
我去掉这句代码,错误是没有了,但是 exe 还是打不开 是不是注册不成功呢?
请高手指点一二,先谢过了!!!