2024-11-11 12:14:44 +04:00
|
|
|
|
// Lab61.cpp : Определяет точку входа для приложения.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "framework.h"
|
2024-11-11 12:30:59 +04:00
|
|
|
|
#include "Lab62.h"
|
2024-11-11 12:14:44 +04:00
|
|
|
|
|
|
|
|
|
#define MAX_LOADSTRING 100
|
|
|
|
|
|
|
|
|
|
// Глобальные переменные:
|
|
|
|
|
HINSTANCE hInst; // текущий экземпляр
|
|
|
|
|
WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка
|
|
|
|
|
WCHAR szWindowClass[MAX_LOADSTRING]; // имя класса главного окна
|
|
|
|
|
|
|
|
|
|
// Отправить объявления функций, включенных в этот модуль кода:
|
|
|
|
|
ATOM MyRegisterClass(HINSTANCE hInstance);
|
|
|
|
|
BOOL InitInstance(HINSTANCE, int);
|
|
|
|
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
|
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
|
|
|
|
|
|
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
|
|
|
|
_In_opt_ HINSTANCE hPrevInstance,
|
|
|
|
|
_In_ LPWSTR lpCmdLine,
|
|
|
|
|
_In_ int nCmdShow)
|
|
|
|
|
{
|
|
|
|
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
|
|
|
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
|
|
|
|
|
|
|
|
|
// TODO: Разместите код здесь.
|
|
|
|
|
|
|
|
|
|
// Инициализация глобальных строк
|
|
|
|
|
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
|
|
|
|
LoadStringW(hInstance, IDC_LAB61, szWindowClass, MAX_LOADSTRING);
|
|
|
|
|
MyRegisterClass(hInstance);
|
|
|
|
|
|
|
|
|
|
// Выполнить инициализацию приложения:
|
|
|
|
|
if (!InitInstance (hInstance, nCmdShow))
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LAB61));
|
|
|
|
|
|
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
|
|
// Цикл основного сообщения:
|
|
|
|
|
while (GetMessage(&msg, nullptr, 0, 0))
|
|
|
|
|
{
|
|
|
|
|
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
|
|
|
|
{
|
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (int) msg.wParam;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// ФУНКЦИЯ: MyRegisterClass()
|
|
|
|
|
//
|
|
|
|
|
// ЦЕЛЬ: Регистрирует класс окна.
|
|
|
|
|
//
|
|
|
|
|
ATOM MyRegisterClass(HINSTANCE hInstance)
|
|
|
|
|
{
|
|
|
|
|
WNDCLASSEXW wcex;
|
|
|
|
|
|
|
|
|
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
|
|
|
|
|
|
|
|
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
|
wcex.lpfnWndProc = WndProc;
|
|
|
|
|
wcex.cbClsExtra = 0;
|
|
|
|
|
wcex.cbWndExtra = 0;
|
|
|
|
|
wcex.hInstance = hInstance;
|
|
|
|
|
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_LAB61));
|
|
|
|
|
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
|
|
|
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
|
|
|
|
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_LAB61);
|
|
|
|
|
wcex.lpszClassName = szWindowClass;
|
|
|
|
|
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
|
|
|
|
|
|
|
|
|
return RegisterClassExW(&wcex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// ФУНКЦИЯ: InitInstance(HINSTANCE, int)
|
|
|
|
|
//
|
|
|
|
|
// ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно
|
|
|
|
|
//
|
|
|
|
|
// КОММЕНТАРИИ:
|
|
|
|
|
//
|
|
|
|
|
// В этой функции маркер экземпляра сохраняется в глобальной переменной, а также
|
|
|
|
|
// создается и выводится главное окно программы.
|
|
|
|
|
//
|
|
|
|
|
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|
|
|
|
{
|
|
|
|
|
hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной
|
|
|
|
|
|
|
|
|
|
HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
|
|
|
|
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
|
|
|
|
|
|
|
|
|
|
if (!hWnd)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ShowWindow(hWnd, nCmdShow);
|
|
|
|
|
UpdateWindow(hWnd);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM)
|
|
|
|
|
//
|
|
|
|
|
// ЦЕЛЬ: Обрабатывает сообщения в главном окне.
|
|
|
|
|
//
|
|
|
|
|
// WM_COMMAND - обработать меню приложения
|
|
|
|
|
// WM_PAINT - Отрисовка главного окна
|
|
|
|
|
// WM_DESTROY - отправить сообщение о выходе и вернуться
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
|
{
|
|
|
|
|
switch (message)
|
|
|
|
|
{
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
|
{
|
|
|
|
|
int wmId = LOWORD(wParam);
|
|
|
|
|
// Разобрать выбор в меню:
|
|
|
|
|
switch (wmId)
|
|
|
|
|
{
|
|
|
|
|
case IDM_ABOUT:
|
|
|
|
|
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
|
|
|
|
break;
|
|
|
|
|
case IDM_EXIT:
|
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_PAINT:
|
|
|
|
|
{
|
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
|
HDC hdc = BeginPaint(hWnd, &ps);
|
|
|
|
|
// TODO: Добавьте сюда любой код прорисовки, использующий HDC...
|
|
|
|
|
|
|
|
|
|
// Roof
|
|
|
|
|
MoveToEx(hdc, 90, 235, NULL);
|
|
|
|
|
LineTo(hdc, 225, 120);
|
|
|
|
|
LineTo(hdc, 370, 235);
|
|
|
|
|
// house
|
|
|
|
|
LineTo(hdc, 370, 353);
|
|
|
|
|
LineTo(hdc, 90, 353);
|
|
|
|
|
LineTo(hdc, 90, 235);
|
|
|
|
|
LineTo(hdc, 370, 235);
|
|
|
|
|
// Window
|
|
|
|
|
MoveToEx(hdc, 110, 260, NULL);
|
|
|
|
|
LineTo(hdc, 110, 315);
|
|
|
|
|
LineTo(hdc, 200, 315);
|
|
|
|
|
LineTo(hdc, 200, 260);
|
|
|
|
|
LineTo(hdc, 110, 260);
|
|
|
|
|
// Door
|
|
|
|
|
MoveToEx(hdc, 265, 355, NULL);
|
|
|
|
|
LineTo(hdc, 265, 280);
|
|
|
|
|
LineTo(hdc, 320, 280);
|
|
|
|
|
LineTo(hdc, 320, 355);
|
|
|
|
|
// El
|
|
|
|
|
HPEN hPen;
|
|
|
|
|
hPen = CreatePen(PS_SOLID, 5, RGB(57, 255, 20));
|
|
|
|
|
SelectObject(hdc, hPen);
|
|
|
|
|
MoveToEx(hdc, 420, 350, NULL);
|
|
|
|
|
LineTo(hdc, 420, 300);
|
|
|
|
|
MoveToEx(hdc, 390, 300, NULL);
|
|
|
|
|
LineTo(hdc, 450, 300);
|
|
|
|
|
LineTo(hdc, 420, 275);
|
|
|
|
|
LineTo(hdc, 390, 300);
|
|
|
|
|
MoveToEx(hdc, 400, 275, NULL);
|
|
|
|
|
LineTo(hdc, 440, 275);
|
|
|
|
|
LineTo(hdc, 420, 255);
|
|
|
|
|
LineTo(hdc, 400, 275);
|
|
|
|
|
MoveToEx(hdc, 410, 255, NULL);
|
|
|
|
|
LineTo(hdc, 435, 255);
|
|
|
|
|
LineTo(hdc, 425, 235);
|
|
|
|
|
LineTo(hdc, 410, 255);
|
|
|
|
|
hPen = CreatePen(PS_SOLID, 2, RGB(0, 0, 0));
|
|
|
|
|
SelectObject(hdc, hPen);
|
|
|
|
|
// 1 kust
|
|
|
|
|
int x1 = 400, y1 = 150;
|
|
|
|
|
|
|
|
|
|
int x2 = 500, y2 = 250;
|
|
|
|
|
do {
|
|
|
|
|
MoveToEx(hdc, x1, y1, NULL);
|
|
|
|
|
LineTo(hdc, x2, y2);
|
|
|
|
|
x1 += 5;
|
|
|
|
|
} while (x1<= 600);
|
|
|
|
|
|
|
|
|
|
//2 kust
|
|
|
|
|
int m1 = 600, n1 = 250;
|
|
|
|
|
int m2 = 700, n2 = 250;
|
|
|
|
|
do {
|
|
|
|
|
MoveToEx(hdc, m1, n1, NULL);
|
|
|
|
|
LineTo(hdc, m2, n2);
|
|
|
|
|
m1 += 5;
|
|
|
|
|
n1 -= 10;
|
|
|
|
|
} while (m1 <=700);
|
|
|
|
|
m1 = 700;
|
|
|
|
|
n1 = 50;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
MoveToEx(hdc, m1, n1, NULL);
|
|
|
|
|
LineTo(hdc, m2, n2);
|
|
|
|
|
m1 += 5;
|
|
|
|
|
n1 += 10;
|
|
|
|
|
} while (m1 <=800);
|
|
|
|
|
//zabor
|
|
|
|
|
int z1 = 300, i1 = 30;
|
|
|
|
|
int z2 = 300, i2 = 130;
|
|
|
|
|
do {
|
|
|
|
|
MoveToEx(hdc, z1, i1, NULL);
|
|
|
|
|
LineTo(hdc, z2, i2);
|
|
|
|
|
z1 += 4;
|
|
|
|
|
z2 += 4;
|
|
|
|
|
} while (z1<=550);
|
|
|
|
|
//uzor
|
|
|
|
|
|
|
|
|
|
int a1 = 170, b1 = 220;
|
|
|
|
|
int a2 = 220, b2 = 220;
|
|
|
|
|
do {
|
|
|
|
|
MoveToEx(hdc, a1, b1, NULL);
|
|
|
|
|
LineTo(hdc, a2, b2);
|
|
|
|
|
a1 += 5;
|
|
|
|
|
b1 -= 10;
|
|
|
|
|
} while (a1 <= 220);
|
|
|
|
|
a1 = 220;
|
|
|
|
|
b1 = 70;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
MoveToEx(hdc, a1, b1, NULL);
|
|
|
|
|
LineTo(hdc, a2, b2);
|
|
|
|
|
a1 += 5;
|
|
|
|
|
b1 += 10;
|
|
|
|
|
} while (a1 <= 295);
|
|
|
|
|
//zabor 2
|
|
|
|
|
int c1 = 20, d1 = 310;
|
|
|
|
|
int c2 = 20, d2 = 360;
|
|
|
|
|
do {
|
|
|
|
|
MoveToEx(hdc, c1, d1, NULL);
|
|
|
|
|
LineTo(hdc, c2, d2);
|
|
|
|
|
c1 += 15;
|
|
|
|
|
c2 += 15;
|
|
|
|
|
} while (c1 <= 500);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
|
PostQuitMessage(0);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Обработчик сообщений для окна "О программе".
|
|
|
|
|
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
|
{
|
|
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
|
switch (message)
|
|
|
|
|
{
|
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
|
|
|
|
{
|
|
|
|
|
EndDialog(hDlg, LOWORD(wParam));
|
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return (INT_PTR)FALSE;
|
|
|
|
|
}
|