Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- int CALLBACK wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR szCmdLine, int nCmdShow)
- {
- MSG msg{};
- HWND hwnd{};
- WNDCLASSEX wc{ sizeof(WNDCLASSEX) };
- wc.hbrBackground = CreateSolidBrush(RGB(240, 240, 240));
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- wc.hInstance = hInstance;
- wc.lpfnWndProc = WndProc;
- wc.lpszClassName = L"MyClass";
- wc.style = CS_VREDRAW | CS_HREDRAW;
- if (!RegisterClassEx(&wc))
- return EXIT_FAILURE;
- if (hwnd = CreateWindowW(wc.lpszClassName, L"Lab1", WS_OVERLAPPEDWINDOW, 0, 0, 600, 300, NULL, NULL, wc.hInstance, NULL); hwnd == INVALID_HANDLE_VALUE)
- return EXIT_FAILURE;
- ShowWindow(hwnd, nCmdShow);
- UpdateWindow(hwnd);
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return EXIT_SUCCESS;
- }
- LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- const wchar_t text[20] = L"I LOVE AIP";
- static HWND Text;
- static HWND Button;
- static HWND input1;
- static HWND input2;
- switch (uMsg)
- {
- case WM_DESTROY:
- PostQuitMessage(EXIT_SUCCESS);
- break;
- case WM_CREATE:
- Text = CreateWindowW(L"STATIC", text, WS_CHILD | WS_VISIBLE | SS_CENTER, 0, 10, 100, 30, hWnd, NULL, NULL, NULL);
- Button = CreateWindowW(L"BUTTON", L"Copy", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 360, 70, 100, 30, hWnd, (HMENU)999, NULL, NULL);
- input1 = CreateWindowW(L"EDIT", L"", WS_BORDER | WS_CHILD | WS_VISIBLE | !ES_READONLY, 0, 60, 350, 20, hWnd, NULL, NULL, NULL);
- input2 = CreateWindowW(L"EDIT", L"", WS_BORDER | WS_CHILD | WS_VISIBLE | ES_READONLY, 0, 90, 350, 20, hWnd, NULL, NULL, NULL);
- break;
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case 999:
- WCHAR* buffer = new WCHAR[150];
- GetWindowText(input1, buffer, 150);
- SetWindowText(input2, buffer);
- break;
- }
- break;
- }
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement