#include <windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int CALLBACK WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow) {
static TCHAR szClassName[] = L"directx12";
WNDCLASSEX wc = { 0 };
wc.cbSize = sizeof(wc);
wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = szClassName;
wc.hIconSm = NULL;
if (!RegisterClassEx(&wc)) {
MessageBox(NULL, L"RegisterClassEx Error", L"Title", MB_ICONEXCLAMATION | MB_OK);
return 1;
}
HWND hWnd = CreateWindowEx(
0, szClassName, L"Window Name",
WS_CAPTION | WS_MAXIMIZEBOX | WS_SYSMENU | WS_MINIMIZEBOX,
300, 300, 640, 480,
NULL, NULL, hInstance, NULL);
if (!hWnd) {
MessageBox(NULL, L"hWnd Error", L"Title", MB_ICONEXCLAMATION | MB_OK);
return 1;
}
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
MSG msg = {0};
BOOL result;
while ( (result = GetMessage(&msg, NULL, 0, 0)) ) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (result == -1)
return -1;
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_CLOSE:
PostQuitMessage(69);
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
/*
run:
The program '[8716] test.exe' has exited with code 69 (0x45).
*/