Advertisement
lofojak

5sPP3Task3

Oct 9th, 2024
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 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 <corecrt_math.h>
  8.  
  9. void WinShow(HDC dc)
  10. {
  11.     double x, y; int a = 3;
  12.  
  13.     SelectObject(dc, GetStockObject(DC_BRUSH));
  14.     SetDCBrushColor(dc, RGB(0, 0, 255));
  15.  
  16.     MoveToEx(dc, 20, 280, NULL);
  17.     LineTo(dc, 760, 280);
  18.  
  19.     MoveToEx(dc, 400, 20, NULL);
  20.     LineTo(dc, 400, 540);
  21.  
  22.     SetDCBrushColor(dc, RGB(255, 0, 0));
  23.     for (double t = 0; t < 2 * 3.14; t += 0.001) {
  24.         x = cos(t);
  25.         x = a * x * x * x;
  26.         y = sin(t);
  27.         y = a * y * y * y;
  28.         SetPixel(dc, x * 70 + 400, 280 - y * 70, RGB(255, 0, 0));
  29.     }
  30. }
  31.  
  32.  
  33. LRESULT WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
  34. {
  35.     if (message == WM_DESTROY)
  36.         PostQuitMessage(0);
  37.     else return DefWindowProcA(hwnd, message, wparam, lparam);
  38. }
  39. int main()
  40. {
  41.     WNDCLASSA wcl;
  42.     memset(&wcl, 0, sizeof(WNDCLASSA));
  43.     wcl.lpszClassName = "my_Window";
  44.     wcl.lpfnWndProc = WndProc;
  45.     RegisterClassA(&wcl);
  46.     HWND hwnd;
  47.     hwnd = CreateWindow(L"my_Window", L"        ", WS_OVERLAPPEDWINDOW, 10, 10, 800, 600, NULL, NULL, NULL, NULL);
  48.     HDC dc = GetDC(hwnd);
  49.     ShowWindow(hwnd, SW_SHOWNORMAL);
  50.     MSG msg;
  51.  
  52.     while (GetMessage(&msg, NULL, 0, 0))
  53.     {
  54.         TranslateMessage(&msg);
  55.         DispatchMessage(&msg);
  56.         WinShow(dc);
  57.     }
  58.     return 0;
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement