我的程序无法生成窗口,望大家指点.
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:PostQuitMessage(0);return 0;
}
return 0;
}
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE hPrevinstanc,
LPSTR lpCmdLine,
int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wc.hInstance=hinstance;
wc.lpfnWndProc=WndProc;
wc.lpszClassName="WC";
wc.lpszMenuName=NULL;
wc.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
hwnd=CreateWindow("WC","Sample",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hinstance,NULL);
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}