Advertisement
Deth12

s

Oct 10th, 2019
2,181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Windows.h>
  2.  
  3. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  4.  
  5. int CALLBACK wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR szCmdLine, int nCmdShow)
  6. {
  7.     MSG msg{};
  8.     HWND hwnd{};
  9.     WNDCLASSEX wc{ sizeof(WNDCLASSEX) };
  10.     wc.hbrBackground = CreateSolidBrush(RGB(240, 240, 240));
  11.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  12.     wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  13.     wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  14.     wc.hInstance = hInstance;
  15.     wc.lpfnWndProc = WndProc;
  16.     wc.lpszClassName = L"MyClass";
  17.     wc.style = CS_VREDRAW | CS_HREDRAW;
  18.     if (!RegisterClassEx(&wc))
  19.         return EXIT_FAILURE;
  20.     if (hwnd = CreateWindowW(wc.lpszClassName, L"Lab1", WS_OVERLAPPEDWINDOW, 0, 0, 600, 300, NULL, NULL, wc.hInstance, NULL); hwnd == INVALID_HANDLE_VALUE)
  21.         return EXIT_FAILURE;
  22.     ShowWindow(hwnd, nCmdShow);
  23.     UpdateWindow(hwnd);
  24.     while (GetMessage(&msg, NULL, 0, 0))
  25.     {
  26.         TranslateMessage(&msg);
  27.         DispatchMessage(&msg);
  28.     }
  29.     return EXIT_SUCCESS;
  30. }
  31.  
  32. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  33. {
  34.     const wchar_t text[20] = L"I LOVE AIP";
  35.     static HWND Text;
  36.     static HWND Button;
  37.     static HWND input1;
  38.     static HWND input2;
  39.     switch (uMsg)
  40.     {
  41.     case WM_DESTROY:
  42.         PostQuitMessage(EXIT_SUCCESS);
  43.         break;
  44.     case WM_CREATE:
  45.         Text = CreateWindowW(L"STATIC", text, WS_CHILD | WS_VISIBLE | SS_CENTER, 0, 10, 100, 30, hWnd, NULL, NULL, NULL);
  46.         Button = CreateWindowW(L"BUTTON", L"Copy", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 360, 70, 100, 30, hWnd, (HMENU)999, NULL, NULL);
  47.         input1 = CreateWindowW(L"EDIT", L"", WS_BORDER | WS_CHILD | WS_VISIBLE | !ES_READONLY, 0, 60, 350, 20, hWnd, NULL, NULL, NULL);
  48.         input2 = CreateWindowW(L"EDIT", L"", WS_BORDER | WS_CHILD | WS_VISIBLE | ES_READONLY, 0, 90, 350, 20, hWnd, NULL, NULL, NULL);
  49.         break;
  50.     case WM_COMMAND:
  51.         switch (LOWORD(wParam))
  52.         {
  53.         case 999:
  54.             WCHAR* buffer = new WCHAR[150];
  55.             GetWindowText(input1, buffer, 150);
  56.             SetWindowText(input2, buffer);
  57.             break;
  58.         }
  59.         break;
  60.     }
  61.     return DefWindowProc(hWnd, uMsg, wParam, lParam);
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement