求解决,编译通过了,为啥不有窗口,谢谢!
求解决,编译通过了,为啥不有窗口,谢谢!#include <windows.h>
#include<stdio.h>
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{ HWND hwnd;
WNDCLASS wndcls;
MSG msg;
UNREFERENCED_PARAMETER(lpCmdLine);
wndcls.style=CS_HREDRAW|CS_VREDRAW;
wndcls.lpszMenuName=NULL;
wndcls.lpszClassName="ex1";
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.lpfnWndProc=WndProc;
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hInstance=hInstance;
RegisterClass(&wndcls);
hwnd=CreateWindow("ex1","第一个Windows程序",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0/*(msg.wParam)*/;//原文是返回0;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT uMsg,WPARAM wParam, LPARAM lParam)
{
char *szChar="\0";
switch(uMsg)
{
case WM_CLOSE:
if(IDYES==MessageBox(hwnd, "是否真的结束? ",
"确认结束程序",MB_YESNO))
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CHAR:
sprintf(szChar, "你按下了%c",wParam);
MessageBox(hwnd,szChar, "字符",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd, "你单击了鼠标左键","鼠标单击通知",0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}