Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma(lib, "user32.lib");
- pragma(lib, "gdi32.lib");
- import core.sys.windows.windows;
- import std.string;
- import std.conv;
- __gshared HWND hEdit;
- enum ID_EDIT = 101;
- extern(Windows) nothrow
- LRESULT WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- case WM_CREATE:
- {
- hEdit = CreateWindowEx(
- 0,
- "EDIT",
- null,
- WS_CHILD | WS_VISIBLE |
- WS_VSCROLL | WS_HSCROLL |
- ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
- 0, 0, 500, 400,
- hwnd,
- cast(HMENU) ID_EDIT,
- GetModuleHandle(null),
- null
- );
- return 0;
- }
- case WM_SIZE:
- {
- int width = LOWORD(lParam);
- int height = HIWORD(lParam);
- MoveWindow(hEdit, 0, 0, width, height, TRUE);
- return 0;
- }
- case WM_DESTROY:
- {
- PostQuitMessage(0);
- return 0;
- }
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- }
- void main()
- {
- HINSTANCE hInstance = GetModuleHandle(null);
- WNDCLASS wc;
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = &WndProc;
- wc.hInstance = hInstance;
- wc.hCursor = LoadCursor(null, IDC_ARROW);
- wc.hbrBackground = cast(HBRUSH)(COLOR_WINDOW + 1);
- wc.lpszClassName = "DTextEditor";
- RegisterClass(&wc);
- HWND hwnd = CreateWindowEx(
- 0,
- "DTextEditor",
- "Mini Text Editor - D + Win32",
- WS_OVERLAPPEDWINDOW | WS_VISIBLE,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 800,
- 600,
- null,
- null,
- hInstance,
- null
- );
- ShowWindow(hwnd, SW_SHOW);
- UpdateWindow(hwnd);
- MSG msg;
- while (GetMessage(&msg, null, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment