Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <vector>
- #define _USE_MATH_DEFINES
- #include <math.h>
- #include <Windows.h>
- #include <tchar.h>
- using namespace std;
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- TCHAR WinName[] = _T("MainFrame");
- vector <int> shape;
- int APIENTRY WinMain(HINSTANCE This, HINSTANCE Prev, LPSTR cmd, int mode)
- {
- HWND hWnd;
- MSG msg;
- WNDCLASS wc;
- wc.hInstance = This;
- wc.lpszClassName = WinName;
- wc.lpfnWndProc = WndProc;
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.lpszMenuName = NULL;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- if (!RegisterClass(&wc)) return 0;
- hWnd = CreateWindow(WinName, _T("Каркас Windows-приложения"),
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- HWND_DESKTOP,
- NULL,
- This,
- NULL);
- ShowWindow(hWnd, mode);
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
- PAINTSTRUCT ps;
- HDC hdc;
- class Vector2D {
- public:
- int step;
- int x1, y1, x2, y2;
- int xaxix1() {
- x1 = 200;
- return x1;
- }
- int xaxix2() {
- x2 = 0;
- return x2;
- }
- int yaxix1() {
- y1 = 100;
- return y1;
- }
- int yaxix2() {
- y2 = -100;
- return y2;
- }
- void setstep() {
- step = 200;
- }
- int getstep() {
- return step;
- }
- };
- Vector2D v;
- Vector2D p;
- int step;
- v.setstep();
- static int sx, sy;
- static HPEN hpen;
- int a, b, x1, y1=p.yaxix1(), x2, y2=p.yaxix2();
- switch (message) {
- case WM_CREATE:
- hpen = CreatePen(PS_SOLID, 2, RGB(0, 0, 255));
- break;
- case WM_SIZE:
- sx = LOWORD(lParam);
- sy = HIWORD(lParam);
- break;
- case WM_PAINT:
- hdc = BeginPaint(hWnd, &ps);
- a = sx / 2;
- b = sy / 2;
- SelectObject(hdc, hpen);
- for (int i = 0; i < 3; i++) {
- x1 = p.xaxix1();
- x2 = p.xaxix2();
- y1 += v.getstep();
- y2 += v.getstep();
- for (int j = 0; j < 3; j++) {
- x1 += v.getstep();
- x2 += v.getstep();
- Ellipse(hdc, x1, y1, x2, y2);
- }
- }
- EndPaint(hWnd, &ps);
- break;
- case WM_DESTROY:
- DeleteObject(hpen);
- PostQuitMessage(0);
- break;
- default: return DefWindowProc(hWnd, message, wParam, lParam);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement