#include <windows.h>
#include <tchar.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow) {
static TCHAR szClassName[] = L"directx";
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 = GetSysColorBrush(COLOR_3DFACE);
wc.lpszMenuName = NULL;
wc.lpszClassName = szClassName;
wc.hIconSm = NULL;
if (!RegisterClassEx(&wc)) {
return 1;
}
HWND hWnd = CreateWindowEx(
0, szClassName, L"Window Title",
WS_CAPTION | WS_MAXIMIZEBOX | WS_SYSMENU,
300, 300, 640, 480, NULL, NULL, hInstance, NULL);
if (!hWnd) {
return 1;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
MSG msg = { 0 };
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
static TCHAR arr[512] = L"";
static int i = 0;
switch (uMsg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_CHAR:
arr[i++] = (char)wParam;
SetWindowText(hWnd, arr);
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
/*
run:
*/