#include<Windows.h>
#include<stdio.h>
LRESULT CALLBACK abc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI Winmain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra = 0;
wndcls.cbWndExtra = 0;
wndcls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndcls.hCursor = LoadCursor(NULL, IDC_CROSS);
wndcls.hIcon = LoadIcon(NULL, IDI_ERROR);
wndcls.hInstance = hInstance;
wndcls.lpfnWndProc = abc;
wndcls.lpszClassName = "c++ GAME";
wndcls.lpszMenuName = NULL;
wndcls.style = CS_HREDRAW;
RegisterClass(&wndcls); //注册窗口
HWND hwnd;
hwnd = CreateWindow(
"c++ GAME",
"123",
WS_OVERLAPPEDWINDOW,
200, 200, 600, 400,
NULL, NULL, hInstance,NULL
);
ShowWindow(hwnd, SW_NORMAL);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK abc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
){
switch (uMsg)
{
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc, 0, 0, "hello", strlen("hello"));
EndPaint(hwnd, &ps);
break;
case WM_CLOSE:
if (IDYES == MessageBox(hwnd, "是否真的结束?", "游戏", MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}