-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.d
More file actions
73 lines (61 loc) · 1.58 KB
/
Copy pathhello.d
File metadata and controls
73 lines (61 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import core.runtime;
import core.sys.windows.windows;
pragma(lib, "gdi32.lib");
int main()
{
const string className = "HelloWinClass";
HWND hwnd;
MSG msg;
HMODULE hInstance = GetModuleHandleA(null);
WNDCLASSA wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = cast(WNDPROC)&WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIconA(null, IDI_APPLICATION);
wndclass.hCursor = LoadCursorA(null, IDC_ARROW);
wndclass.hbrBackground = cast(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = null;
wndclass.lpszClassName = cast(char *)className;
if (!RegisterClassA(&wndclass))
{
MessageBoxA(null, "Error registering window class", cast(char *)className, MB_ICONERROR);
return 1;
}
hwnd = CreateWindowA(cast(char *)className,
"Hello World",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
null,
null,
hInstance,
null);
if (!hwnd)
{
MessageBoxA(null, "Error creating window", cast(char *)className, MB_ICONERROR);
return 1;
}
ShowWindow(hwnd, SW_SHOWNORMAL);
UpdateWindow(hwnd);
while (GetMessageA(&msg, null, 0, 0))
{
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
return msg.wParam;
}
extern(Windows) LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
}
return DefWindowProcA(hwnd, message, wParam, lParam);
}