#include <windows.h>
// Этот коллбэк будет вызываться операционной системой, когда она захочет
// передать какую-либо информацию.
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
int CALLBACK WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine,
int nCmdShow) {
MSG msg;
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = &WindowProc; // Передача ссылки на функцию
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInst;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = "MainWindowClass";
if (!RegisterClass(&wc))
return FALSE;
HWND hWnd = CreateWindow(wc.lpszClassName, "Hello World",
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, (HWND)NULL, (HMENU)NULL, hInst, (LPVOID)NULL);
if (!hWnd)
return FALSE;
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
BOOL bRet;
while ((bRet = GetMessageA(&msg, NULL, 0, 0)) != 0) {
if (bRet == -1) {
return GetLastError();
} else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
// Return the exit code to the system.
return msg.wParam;
}
I2luY2x1ZGUgPHdpbmRvd3MuaD4KCi8vINCt0YLQvtGCINC60L7Qu9C70LHRjdC6INCx0YPQtNC10YIg0LLRi9C30YvQstCw0YLRjNGB0Y8g0L7Qv9C10YDQsNGG0LjQvtC90L3QvtC5INGB0LjRgdGC0LXQvNC+0LksINC60L7Qs9C00LAg0L7QvdCwINC30LDRhdC+0YfQtdGCCi8vICAg0L/QtdGA0LXQtNCw0YLRjCDQutC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