Advertisement
Guest User

pasta

a guest
Jan 15th, 2019
196
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 = 10;
  11. int iteratorr = 0;
  12. POINT point[14];
  13. HDC hdc, mdc;
  14. HPEN Pen, Pen_box;
  15. HBRUSH Brush, Brush_box;
  16. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  17. {
  18.    
  19.     switch (msg)
  20.     {
  21.     case WM_PAINT:
  22.     {  
  23.         PAINTSTRUCT ps;
  24.         BeginPaint(hwnd, &ps);
  25.  
  26.         RECT rect;
  27.         GetClientRect(hwnd, &rect);
  28.         Pen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
  29.         Brush = CreateSolidBrush(RGB(0, 255, 0));
  30.  
  31.         SetMapMode(mdc, MM_ISOTROPIC);
  32.         SetWindowExtEx(mdc, 400, 400, NULL);
  33.         SetViewportExtEx(mdc, rect.right, -rect.bottom, NULL);
  34.         SetViewportOrgEx(mdc, rect.right / 2, rect.bottom / 2, NULL);
  35.    
  36.         HDC hdc;
  37.         hdc = GetDC(hwnd);
  38.         POINT point[3];
  39.         point[0].x = 0;
  40.         point[0].y = 0;
  41.         point[1].x = 100;
  42.         point[1].y = 0;
  43.         point[2].x = 100;
  44.         point[2].y = 100;
  45.         Polygon(hdc, point, 3);
  46.         EndPaint(hwnd, &ps);
  47.         break;
  48.     }
  49.     case WM_COMMAND:
  50.     {  
  51.         break;
  52.     }
  53.     case WM_CLOSE:
  54.     {
  55.         //if (MessageBox(NULL, TEXT("Serio chcesz zamknac?"), TEXT("Warning"), MB_YESNO) == IDYES)
  56.             DestroyWindow(hwnd);
  57.         break;
  58.     }
  59.     case WM_DESTROY:
  60.     {
  61.         PostQuitMessage(1);
  62.     }
  63.     break;
  64.  
  65.  
  66.     default:
  67.         return DefWindowProc(hwnd, msg, wParam, lParam);
  68.     }
  69.  
  70.     return 0;
  71. }
  72. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hprevInstance, LPSTR lpCmdLine, int nCmdShow)
  73. {
  74.  
  75.     //tworzenie klasy okno
  76.  
  77.     WNDCLASSEX wc;
  78.  
  79.  
  80.     wc.cbSize = sizeof(WNDCLASSEX);
  81.     wc.style = CS_VREDRAW | CS_HREDRAW;
  82.     wc.lpfnWndProc = WndProc;
  83.     wc.cbClsExtra = 0;
  84.     wc.cbWndExtra = 0;
  85.     wc.hInstance = hInstance;
  86.     wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  87.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  88.     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 0);
  89.     wc.lpszMenuName = NULL;
  90.     wc.lpszClassName = NazwaKlasy;
  91.     wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  92.     if (!RegisterClassEx(&wc))
  93.     {
  94.         MessageBox(NULL, "Odmowa okna", "ww", MB_ICONEXCLAMATION | MB_OK);
  95.         return 1;
  96.     }
  97.     hwnd = CreateWindowEx(WS_EX_WINDOWEDGE, NazwaKlasy, "Oto Okienko", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 800, NULL, NULL, hInstance, NULL);
  98.     if (hwnd == 0)
  99.     {
  100.         MessageBox(NULL, "Nie działa", "Ojć", MB_ICONEXCLAMATION);
  101.         return 1;
  102.     }
  103.     ShowWindow(hwnd, nCmdShow);
  104.     UpdateWindow(hwnd);
  105.  
  106.  
  107.    
  108.  
  109.     //Petla przechwytujaca kounikaty
  110.     while (GetMessage(&Komunikat, NULL, 0, 0))
  111.     {
  112.         TranslateMessage(&Komunikat);
  113.         DispatchMessage(&Komunikat);
  114.     }
  115.  
  116.     UnregisterClass(NazwaKlasy, hInstance);
  117.     return Komunikat.wParam;
  118.  
  119.  
  120.     while (GetMessage(&Komunikat, NULL, 0, 0))
  121.     {
  122.         TranslateMessage(&Komunikat);
  123.         DispatchMessage(&Komunikat);
  124.     }
  125.  
  126.  
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement