Advertisement
Guest User

nedziala

a guest
Jan 15th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Windows.h>
  2. #include <stdio.h>
  3. #include <vector>
  4.  
  5. //przechwytuje wszytkie komunikaty
  6. MSG Komunikat;
  7. TCHAR NazwaKlasy[] = TEXT("Jestem se klasa");
  8.  
  9. HWND hwnd;
  10. float gwiazdka = 70;
  11. HDC hdc;
  12. HPEN Pen, Pen_box;
  13. HBRUSH Brush, Brush_box;
  14. POINT point[14];
  15. int iterator = 0;
  16. int speed =0;
  17. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  18. {
  19.    
  20.     switch (msg)
  21.     {
  22.    
  23.     case WM_CREATE:
  24.     {
  25.         SetTimer(hwnd, 1, 100, NULL);
  26.         break;
  27.     }
  28.     case WM_PAINT:
  29.     {  
  30.         PAINTSTRUCT ps;
  31.         hdc = BeginPaint(hwnd, &ps);
  32.  
  33.         RECT rect;
  34.         GetClientRect(hwnd, &rect);
  35.         Pen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
  36.         Brush = CreateSolidBrush(RGB(0, 255, 0));
  37.  
  38.         SetMapMode(hdc, MM_ISOTROPIC);
  39.         SetWindowExtEx(hdc, 400, 400, NULL);
  40.         SetViewportExtEx(hdc, rect.right, -rect.bottom, NULL);
  41.         SetViewportOrgEx(hdc, rect.right / 2, rect.bottom / 2, NULL);
  42.         iterator += speed;
  43.         for (int i=0; i < 360; i += 52)
  44.         {
  45.             point[iterator].x = gwiazdka * sin(i * 3.14 / 180);
  46.             point[iterator].y = gwiazdka * cos(i * 3.14 / 180);
  47.             iterator += 2;
  48.         }
  49.         iterator = 1;
  50.         for (int i = 26; i < 360; i += 52)
  51.         {
  52.             point[iterator].x = gwiazdka/2 * sin(i * 3.14 / 180);
  53.             point[iterator].y = gwiazdka/2 * cos(i * 3.14 / 180);
  54.             iterator += 2;
  55.         }
  56.         Pen_box = (HPEN)SelectObject(hdc, Pen);
  57.         Brush_box = (HBRUSH)SelectObject(hdc, Brush);
  58.         Polygon(hdc, point, 14);
  59.         SelectObject(hdc, Pen_box);
  60.         SelectObject(hdc, Brush_box);
  61.         DeleteObject(Pen);
  62.         DeleteObject(Brush);
  63.         DeleteObject(Pen_box);
  64.         DeleteObject(Brush_box);
  65.  
  66.         EndPaint(hwnd, &ps);
  67.         break;
  68.     }
  69.     case WM_TIMER:
  70.     {  
  71.    
  72.         InvalidateRect(hwnd, 0, FALSE);
  73.         break;
  74.     }
  75.     case WM_LBUTTONDOWN:
  76.     {
  77.         speed++;
  78.         break;
  79.     }
  80.     case WM_CLOSE:
  81.     {
  82.         if (MessageBox(NULL, TEXT("Serio chcesz zamknac?"), TEXT("Warning"), MB_YESNO) == IDYES)
  83.             DestroyWindow(hwnd);
  84.         break;
  85.     }
  86.     case WM_DESTROY:
  87.     {
  88.         KillTimer(hwnd, 1);
  89.         PostQuitMessage(1);
  90.     }
  91.     break;
  92.  
  93.  
  94.     default:
  95.         return DefWindowProc(hwnd, msg, wParam, lParam);
  96.     }
  97.  
  98.     return 0;
  99. }
  100. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hprevInstance, LPSTR lpCmdLine, int nCmdShow)
  101. {
  102.  
  103.     //tworzenie klasy okno
  104.  
  105.     WNDCLASSEX wc;
  106.  
  107.  
  108.     wc.cbSize = sizeof(WNDCLASSEX);
  109.     wc.style = CS_VREDRAW | CS_HREDRAW;
  110.     wc.lpfnWndProc = WndProc;
  111.     wc.cbClsExtra = 0;
  112.     wc.cbWndExtra = 0;
  113.     wc.hInstance = hInstance;
  114.     wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  115.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  116.     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 0);
  117.     wc.lpszMenuName = NULL;
  118.     wc.lpszClassName = NazwaKlasy;
  119.     wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  120.     if (!RegisterClassEx(&wc))
  121.     {
  122.         MessageBox(NULL, "Odmowa okna", "ww", MB_ICONEXCLAMATION | MB_OK);
  123.         return 1;
  124.     }
  125.     hwnd = CreateWindowEx(WS_EX_WINDOWEDGE, NazwaKlasy, "Oto Okienko", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 800, NULL, NULL, hInstance, NULL);
  126.     if (hwnd == 0)
  127.     {
  128.         MessageBox(NULL, "Nie działa", "Ojć", MB_ICONEXCLAMATION);
  129.         return 1;
  130.     }
  131.     ShowWindow(hwnd, nCmdShow);
  132.     UpdateWindow(hwnd);
  133.  
  134.  
  135.    
  136.  
  137.     //Petla przechwytujaca kounikaty
  138.     while (GetMessage(&Komunikat, NULL, 0, 0))
  139.     {
  140.         TranslateMessage(&Komunikat);
  141.         DispatchMessage(&Komunikat);
  142.     }
  143.  
  144.     UnregisterClass(NazwaKlasy, hInstance);
  145.     return Komunikat.wParam;
  146.  
  147.  
  148.     while (GetMessage(&Komunikat, NULL, 0, 0))
  149.     {
  150.         TranslateMessage(&Komunikat);
  151.         DispatchMessage(&Komunikat);
  152.     }
  153.  
  154.  
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement