#include<windows.h>
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WINMIAN
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS wndclass;
wndclass.cbClsExtra =0;
wndclass.cbWndExtra =0;
wndclass.hbrBackground =(HBRUSH)GetStockObject(GRAY_BRUSH);
wndclass.hCursor =LoadCursor(NULL,IDC_CROSS);
wndclass.hIcon =LoadIcon(NULL,IDI_WINLOGO);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc =WindowProc;
wndclass.lpszClassName ="firstwindow";
wndclass.lpszMenuName =NULL;
wndclass.style =CS_HREDRAW|CS_VREDRAW|CS_NOCLOSE;
RegisterClass(&wndclass);
HWND hwnd;
hwnd=CreateWindow("firstwindow","an easy window",WS_OVERLAPPED,CW_USEDEFAULT ,
CW_USEDEFAULT ,CW_USEDEFAULT ,CW_USEDEFAULT ,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
break;
case WM_LBUTTONDOWN:
break;
case WM_PAINT:
break;
case WM_CLOSE:
/*if(MessageBox(hwnd,"是否要关闭窗口?","提示",0)==IDYES)
{
DestroyWindow(hwnd);
}*/
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
--------------------Configuration: 1 - Win32 Debug--------------------
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
1.exe - 2 error(s), 0 warning(s)