Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <stdio.h>
- #include <vector>
- //przechwytuje wszytkie komunikaty
- MSG Komunikat;
- TCHAR NazwaKlasy[] = TEXT("Jestem se klasa");
- HWND hwnd;
- float gwiazdka = 70;
- HDC hdc;
- HPEN Pen, Pen_box;
- HBRUSH Brush, Brush_box;
- POINT point[14];
- int iterator = 0;
- int speed =0;
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- case WM_CREATE:
- {
- SetTimer(hwnd, 1, 100, NULL);
- break;
- }
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- hdc = BeginPaint(hwnd, &ps);
- RECT rect;
- GetClientRect(hwnd, &rect);
- Pen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
- Brush = CreateSolidBrush(RGB(0, 255, 0));
- SetMapMode(hdc, MM_ISOTROPIC);
- SetWindowExtEx(hdc, 400, 400, NULL);
- SetViewportExtEx(hdc, rect.right, -rect.bottom, NULL);
- SetViewportOrgEx(hdc, rect.right / 2, rect.bottom / 2, NULL);
- iterator += speed;
- for (int i=0; i < 360; i += 52)
- {
- point[iterator].x = gwiazdka * sin(i * 3.14 / 180);
- point[iterator].y = gwiazdka * cos(i * 3.14 / 180);
- iterator += 2;
- }
- iterator = 1;
- for (int i = 26; i < 360; i += 52)
- {
- point[iterator].x = gwiazdka/2 * sin(i * 3.14 / 180);
- point[iterator].y = gwiazdka/2 * cos(i * 3.14 / 180);
- iterator += 2;
- }
- Pen_box = (HPEN)SelectObject(hdc, Pen);
- Brush_box = (HBRUSH)SelectObject(hdc, Brush);
- Polygon(hdc, point, 14);
- SelectObject(hdc, Pen_box);
- SelectObject(hdc, Brush_box);
- DeleteObject(Pen);
- DeleteObject(Brush);
- DeleteObject(Pen_box);
- DeleteObject(Brush_box);
- EndPaint(hwnd, &ps);
- break;
- }
- case WM_TIMER:
- {
- InvalidateRect(hwnd, 0, FALSE);
- break;
- }
- case WM_LBUTTONDOWN:
- {
- speed++;
- break;
- }
- case WM_CLOSE:
- {
- if (MessageBox(NULL, TEXT("Serio chcesz zamknac?"), TEXT("Warning"), MB_YESNO) == IDYES)
- DestroyWindow(hwnd);
- break;
- }
- case WM_DESTROY:
- {
- KillTimer(hwnd, 1);
- PostQuitMessage(1);
- }
- break;
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return 0;
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hprevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- //tworzenie klasy okno
- WNDCLASSEX wc;
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.style = CS_VREDRAW | CS_HREDRAW;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 0);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = NazwaKlasy;
- wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- if (!RegisterClassEx(&wc))
- {
- MessageBox(NULL, "Odmowa okna", "ww", MB_ICONEXCLAMATION | MB_OK);
- return 1;
- }
- hwnd = CreateWindowEx(WS_EX_WINDOWEDGE, NazwaKlasy, "Oto Okienko", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 800, NULL, NULL, hInstance, NULL);
- if (hwnd == 0)
- {
- MessageBox(NULL, "Nie działa", "Ojć", MB_ICONEXCLAMATION);
- return 1;
- }
- ShowWindow(hwnd, nCmdShow);
- UpdateWindow(hwnd);
- //Petla przechwytujaca kounikaty
- while (GetMessage(&Komunikat, NULL, 0, 0))
- {
- TranslateMessage(&Komunikat);
- DispatchMessage(&Komunikat);
- }
- UnregisterClass(NazwaKlasy, hInstance);
- return Komunikat.wParam;
- while (GetMessage(&Komunikat, NULL, 0, 0))
- {
- TranslateMessage(&Komunikat);
- DispatchMessage(&Komunikat);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement