Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Lab_7.cpp
- #include "stdafx.h"
- #include <iostream>
- #include <windows.h>
- using namespace std;
- class Rect
- {
- public:
- virtual void print()
- {
- cout << "\nI'm a rectangle\n\n\n\n";
- POINT op;
- HWND hWnd = GetConsoleWindow(); //Получаем дескриптор окна консоли
- HDC hDC = GetDC(hWnd); //Получаем контекст устройства по полученному дескриптору
- Rectangle(hDC, 150, 40, 310, 80);
- ReleaseDC(hWnd, hDC);
- }
- };
- class Button : public Rect
- {
- public:
- void print()
- {
- cout << "\nI'm a button\n\n\n\n";
- POINT op;
- HWND hWnd = GetConsoleWindow();
- HDC hDC = GetDC(hWnd);
- SelectObject(hDC, GetStockObject(WHITE_PEN));
- MoveToEx(hDC, 150, 100, &op); LineTo(hDC, 310, 100);
- MoveToEx(hDC, 310, 100, &op); LineTo(hDC, 310, 140);
- MoveToEx(hDC, 310, 140, &op); LineTo(hDC, 150, 140);
- MoveToEx(hDC, 150, 140, &op); LineTo(hDC, 150, 100);
- //
- MoveToEx(hDC, 145, 95, &op); LineTo(hDC, 150, 100);
- MoveToEx(hDC, 315, 95, &op); LineTo(hDC, 310, 100);
- MoveToEx(hDC, 315, 145, &op); LineTo(hDC, 310, 140);
- MoveToEx(hDC, 145, 145, &op); LineTo(hDC, 150, 140);
- //
- MoveToEx(hDC, 145, 95, &op); LineTo(hDC, 315, 95);
- MoveToEx(hDC, 315, 95, &op); LineTo(hDC, 315, 145);
- MoveToEx(hDC, 315, 145, &op); LineTo(hDC, 145, 145);
- MoveToEx(hDC, 145, 145, &op); LineTo(hDC, 145, 95);
- ReleaseDC(hWnd, hDC);
- }
- };
- class FloatButton : public Rect
- {
- public:
- void print()
- {
- cout << "\nI'm a floatButton\n\n\n\n\n";
- POINT op;
- HWND hWnd = GetConsoleWindow();
- HDC hDC = GetDC(hWnd);
- Ellipse(hDC, 150, 200, 250, 300);
- Ellipse(hDC, 175, 225, 225, 275);
- Ellipse(hDC, 185, 235, 215, 265);
- }
- };
- int main()
- {
- Rect rect, *rect_p = ▭
- Button button, *button_p = &button;
- Rect *R1 = &button;
- FloatButton Fbutton, *Fbutton_p = &Fbutton;
- Rect *R2 = &Fbutton;
- rect_p->print(); // rect
- button_p->print(); // button
- R1->print(); // button
- R2->print(); //floatButton
- cout << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment