Advertisement
lofojak

5sPP3Task1

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