Advertisement
lofojak

5sPP3Task5

Oct 9th, 2024
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define _WIN32_WINNT 0X0A00
  5.  
  6. #include <windows.h>
  7. #include <time.h>
  8. #include <corecrt_math.h>
  9.  
  10. void WinShow(HDC dc)
  11. {
  12.     SelectObject(dc, GetStockObject(DC_BRUSH));
  13.     SelectObject(dc, GetStockObject(DC_PEN));
  14.     SetDCPenColor(dc, RGB(0, 0, 0));
  15.     SetDCBrushColor(dc, RGB(255, 255, 0));
  16.  
  17.     Ellipse(dc, 325, 225, 475, 375);
  18.  
  19.     SetDCBrushColor(dc, RGB(0, 255, 255));
  20.  
  21.     int x = 0, y = 0;
  22.     for (double t = 0; t < 2 * 3.1415; t += 0.01) {
  23.         SetDCBrushColor(dc, RGB(255, 255, 255));
  24.         SetDCPenColor(dc, RGB(255, 255, 255));
  25.         Ellipse(dc, x - 26, y - 26, x + 26, y + 26);
  26.  
  27.         x = 400 + (int)(125 * cos(t));
  28.         y = 300 - (int)(125 * sin(t));
  29.  
  30.         SetDCBrushColor(dc, RGB(0, 255, 255));
  31.         SetDCPenColor(dc, RGB(0, 0, 0));
  32.         Ellipse(dc, x - 25, y - 25, x + 25, y + 25);
  33.  
  34.         Sleep(10);
  35.     }
  36. }
  37.  
  38.  
  39. LRESULT WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
  40. {
  41.     if (message == WM_DESTROY)
  42.         PostQuitMessage(0);
  43.     else return DefWindowProcA(hwnd, message, wparam, lparam);
  44. }
  45. int main()
  46. {
  47.     srand(time(NULL));
  48.     WNDCLASSA wcl;
  49.     memset(&wcl, 0, sizeof(WNDCLASSA));
  50.     wcl.lpszClassName = "my_Window";
  51.     wcl.lpfnWndProc = WndProc;
  52.     RegisterClassA(&wcl);
  53.     HWND hwnd;
  54.     hwnd = CreateWindow(L"my_Window", L"Окошечко", WS_OVERLAPPEDWINDOW, 10, 10, 800, 600, NULL, NULL, NULL, NULL);
  55.     HDC dc = GetDC(hwnd);
  56.     ShowWindow(hwnd, SW_SHOWNORMAL);
  57.     MSG msg;
  58.  
  59.     while (GetMessage(&msg, NULL, 0, 0))
  60.     {
  61.         TranslateMessage(&msg);
  62.         DispatchMessage(&msg);
  63.         WinShow(dc);
  64.     }
  65.     return 0;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement