import core.runtime; import std.c.windows.windows; import std.string; extern(Windows) LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_PAINT: PAINTSTRUCT ps; HDC hdc = BeginPaint( hWnd, &ps ); enum text = "Hello, Win32 GUI(D) World!"; TextOutA( hdc, 0, 0, text, text.length ); EndPaint( hWnd, &ps ); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProcA(hWnd, message, wParam, lParam); break; } return 0; } extern(Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { string className = "helloWindow"; string windowName = "Hello, World!"; HWND hWnd; MSG msg; WNDCLASSA wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = &WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIconA(null, IDI_APPLICATION); wc.hCursor = LoadCursorA(null, IDC_ARROW); wc.hbrBackground = cast(HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = null; wc.lpszClassName = className.toStringz; RegisterClassA(&wc); hWnd = CreateWindowA(className.toStringz, windowName.toStringz, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, null, null, hInstance, null); ShowWindow(hWnd, SW_SHOWDEFAULT); UpdateWindow(hWnd); while (GetMessageA(&msg, null, 0, 0)) { TranslateMessage(&msg); DispatchMessageA(&msg); } return msg.wParam; }