app.dhover×24 error×19all
// Minimal Win32 window — the irreducible message-pump sequence GLFW/SDL/winit wrap
// on Windows: RegisterClassExW -> CreateWindowExW -> ShowWindow -> GetMessage /
// DispatchMessage, with a WndProc handling WM_PAINT/WM_DESTROY. Uses druntime's
// built-in `core.sys.windows` bindings (the windows.h projection that ships with
// LDC/DMD) — no third-party. For full SDK coverage the windows-d package is the
// upgrade; see ../index.md (the Win32 OS-API survey).
//
// Bounded: paints once then PostQuitMessage so CI never blocks. Windows always has
// a window station (even on a headless CI runner), so no SKIP gate is needed.
module 
(module) app
app
;
import
(package) core
core
.
(package) core.sys
sys
.
(package) core.sys.windows
windows
.
(module) core.sys.windows.windows

Windows API header module

Translated from MinGW API for MS-Windows 4.0

Source

core/sys/windows/windows.d

windows
;
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.stdio

D header file for C99 <stdio.h>

pubs.opengroup.org/onlinepubs/009695399/basedefs/stdio.h.html, stdio.h

Source

core/stdc/stdio.d

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseDistributed under the Boost Software License 1.0. (See accompanying file LICENSE)@authorsSean Kelly, Alex Rønne Petersen@standardsISO/IEC 9899:1999 (E)
stdio
:
(alias) app.printf = int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
;
extern (Windows) LRESULT
app.wndProc
wndProc
(HWND
(parameter) HWND hwnd
hwnd
, UINT
(parameter) UINT msg
msg
, WPARAM wParam, LPARAM lParam) nothrow
undefined identifier `LRESULT`
undefined identifier `HWND`
undefined identifier `UINT`
undefined identifier `WPARAM`
undefined identifier `LPARAM`
{ switch (msg) { case WM_PAINT: PAINTSTRUCT
_error_ ps
ps
;
HDC
_error_ hdc
hdc
= BeginPaint(hwnd, &ps);
RECT
_error_ rc
rc
;
GetClientRect(hwnd, &rc); FillRect(hdc, &rc, cast(HBRUSH)(COLOR_WINDOW + 1)); EndPaint(hwnd, &ps); PostQuitMessage(0); // bounded: exit after the first paint return 0; case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProcW(hwnd, msg, wParam, lParam); } } int
int D main()
main
()
{ HINSTANCE
(local variable) _error_ hInst
hInst
= GetModuleHandleW(null);
undefined identifier `HINSTANCE`
undefined identifier `GetModuleHandleW`
auto
(local variable) wstring clsName
clsName
= "SparklesWin32"w;
// 1. Register the window class (WndProc + class name). WNDCLASSEXW
(local variable) _error_ wc
wc
;
undefined identifier `WNDCLASSEXW`
wc.cbSize = WNDCLASSEXW.sizeof; wc.lpfnWndProc = &wndProc; wc.hInstance = hInst; wc.lpszClassName = clsName.ptr; wc.hCursor = LoadCursorW(null, IDC_ARROW); if (!RegisterClassExW(&wc))
undefined identifier `RegisterClassExW`
{
int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
("RegisterClassExW failed (%lu)\n", GetLastError());
undefined identifier `GetLastError`
return 1; } // 2. Create a standard overlapped (titled, resizable) top-level window. HWND
(local variable) _error_ hwnd
hwnd
= CreateWindowExW(0, clsName.ptr, "Sparkles · Win32"w.ptr,
undefined identifier `HWND`
undefined identifier `CreateWindowExW`
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 480, 320, null, null, hInst, null); if (hwnd is null) {
int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
("CreateWindowExW failed (%lu)\n", GetLastError());
undefined identifier `GetLastError`
return 1; } // 3. Show it and run the message pump until WM_QUIT. ShowWindow(hwnd, SW_SHOW);
undefined identifier `ShowWindow`
UpdateWindow(hwnd);
undefined identifier `UpdateWindow`
MSG
(local variable) _error_ msg
msg
;
undefined identifier `MSG`
while (GetMessageW(&msg, null, 0, 0) > 0)
undefined identifier `GetMessageW`
{ TranslateMessage(&msg);
undefined identifier `TranslateMessage`
DispatchMessageW(&msg);
undefined identifier `DispatchMessageW`
}
int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
("ok: created a Win32 window and pumped messages to WM_QUIT\n");
return cast(int) msg.wParam; }