#include <Windows.h>
HINSTANCE hins = 0;
HINSTANCE houtput = 0;
void onCreate(HWND hWnd,WPARAM wParam)
{
MessageBox(hWnd,"窗口已被创建","INFOR",MB_OK);
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT msgID,WPARAM wParam,LPARAM lParam)
{
switch(msgID)
{
case WM_CREATE:
OnCreate(hWnd, wParam);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc( hWnd, msgID, wParam, lParam);
}
int CALLBACK WinMain(HINSTANCE hIns,HINSTANCE PreIns,LPSTR IpCmdLine,int nCmdShow)
{
hins = hIns;
houtput = GetStdHandle(STD_OUTPUT_HANDLE);
WNDCLASS wc={0};
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.hCursor = NULL;
wc.hIcon = NULL;
wc.hInstance = hIns;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "Main";
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
HWND hWnd = CreateWindow("Main","window",WS_OVERLAPPEDWINDOW,100,100,500,500,NULL,NULL,hIns,NULL);
ShowWindow(hWnd,SW_SHOW);
UpdateWindow(hWnd);
MSG msg={0};
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}