Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define _WIN32_WINNT 0X0A00
- #include <windows.h>
- #include <time.h>
- #include <corecrt_math.h>
- void WinShow(HDC dc)
- {
- SelectObject(dc, GetStockObject(DC_BRUSH));
- SelectObject(dc, GetStockObject(DC_PEN));
- SetDCPenColor(dc, RGB(0, 0, 0));
- SetDCBrushColor(dc, RGB(255, 255, 0));
- Ellipse(dc, 325, 225, 475, 375);
- SetDCBrushColor(dc, RGB(0, 255, 255));
- int x = 0, y = 0;
- for (double t = 0; t < 2 * 3.1415; t += 0.01) {
- SetDCBrushColor(dc, RGB(255, 255, 255));
- SetDCPenColor(dc, RGB(255, 255, 255));
- Ellipse(dc, x - 26, y - 26, x + 26, y + 26);
- x = 400 + (int)(125 * cos(t));
- y = 300 - (int)(125 * sin(t));
- SetDCBrushColor(dc, RGB(0, 255, 255));
- SetDCPenColor(dc, RGB(0, 0, 0));
- Ellipse(dc, x - 25, y - 25, x + 25, y + 25);
- Sleep(10);
- }
- }
- LRESULT WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
- {
- if (message == WM_DESTROY)
- PostQuitMessage(0);
- else return DefWindowProcA(hwnd, message, wparam, lparam);
- }
- int main()
- {
- srand(time(NULL));
- WNDCLASSA wcl;
- memset(&wcl, 0, sizeof(WNDCLASSA));
- wcl.lpszClassName = "my_Window";
- wcl.lpfnWndProc = WndProc;
- RegisterClassA(&wcl);
- HWND hwnd;
- hwnd = CreateWindow(L"my_Window", L"Окошечко", WS_OVERLAPPEDWINDOW, 10, 10, 800, 600, NULL, NULL, NULL, NULL);
- HDC dc = GetDC(hwnd);
- ShowWindow(hwnd, SW_SHOWNORMAL);
- MSG msg;
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- WinShow(dc);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement