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 = 10;
- int iteratorr = 0;
- POINT point[14];
- HDC hdc, mdc;
- HPEN Pen, Pen_box;
- HBRUSH Brush, Brush_box;
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- BeginPaint(hwnd, &ps);
- RECT rect;
- GetClientRect(hwnd, &rect);
- Pen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
- Brush = CreateSolidBrush(RGB(0, 255, 0));
- SetMapMode(mdc, MM_ISOTROPIC);
- SetWindowExtEx(mdc, 400, 400, NULL);
- SetViewportExtEx(mdc, rect.right, -rect.bottom, NULL);
- SetViewportOrgEx(mdc, rect.right / 2, rect.bottom / 2, NULL);
- HDC hdc;
- hdc = GetDC(hwnd);
- POINT point[3];
- point[0].x = 0;
- point[0].y = 0;
- point[1].x = 100;
- point[1].y = 0;
- point[2].x = 100;
- point[2].y = 100;
- Polygon(hdc, point, 3);
- EndPaint(hwnd, &ps);
- break;
- }
- case WM_COMMAND:
- {
- break;
- }
- case WM_CLOSE:
- {
- //if (MessageBox(NULL, TEXT("Serio chcesz zamknac?"), TEXT("Warning"), MB_YESNO) == IDYES)
- DestroyWindow(hwnd);
- break;
- }
- case WM_DESTROY:
- {
- 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