Advertisement
lofojak

5sPP3Task2

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