2024-11-11 12:14:35 +04:00
|
|
|
|
// Lab51.cpp : Определяет точку входа для приложения.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "framework.h"
|
2024-11-11 12:32:39 +04:00
|
|
|
|
#include "Lab51.h2"
|
2024-11-11 12:14:35 +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_LAB51, szWindowClass, MAX_LOADSTRING);
|
|
|
|
|
MyRegisterClass(hInstance);
|
|
|
|
|
|
|
|
|
|
// Выполнить инициализацию приложения:
|
|
|
|
|
if (!InitInstance (hInstance, nCmdShow))
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LAB51));
|
|
|
|
|
|
|
|
|
|
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_LAB51));
|
|
|
|
|
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
|
|
|
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
|
|
|
|
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_LAB51);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
//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);
|
|
|
|
|
//HBRUSH hBrush;
|
|
|
|
|
//hBrush = CreateSolidBrush(RGB(250, 128, 114));
|
|
|
|
|
//SelectObject(hdc, hBrush);
|
|
|
|
|
//HPEN hPen;
|
|
|
|
|
//hPen = CreatePen(PS_SOLID, 2, RGB(0, 0, 0));
|
|
|
|
|
//SelectObject(hdc, hPen);
|
|
|
|
|
////tree
|
|
|
|
|
//MoveToEx(hdc, 50, 250, NULL);
|
|
|
|
|
//LineTo(hdc, 50, 350);
|
|
|
|
|
//LineTo(hdc, 40, 350);
|
|
|
|
|
//LineTo(hdc, 40, 250);
|
|
|
|
|
//hBrush = CreateSolidBrush(RGB(33, 99,33));
|
|
|
|
|
//SelectObject(hdc, hBrush);
|
|
|
|
|
//Ellipse(hdc, 10, 200, 80, 300);
|
|
|
|
|
//DeleteObject(hBrush);
|
|
|
|
|
//// roof S
|
|
|
|
|
//MoveToEx(hdc, 390, 435, NULL);
|
|
|
|
|
//LineTo(hdc, 525, 300);
|
|
|
|
|
//LineTo(hdc, 670, 435);
|
|
|
|
|
//MoveToEx(hdc, 525, 300, NULL);
|
|
|
|
|
//LineTo(hdc, 670, 280);
|
|
|
|
|
//LineTo(hdc, 790, 420);
|
|
|
|
|
|
|
|
|
|
//// Saray
|
|
|
|
|
//MoveToEx(hdc, 670, 435, NULL);
|
|
|
|
|
//LineTo(hdc, 670, 553);
|
|
|
|
|
//LineTo(hdc, 390, 553);
|
|
|
|
|
//LineTo(hdc, 390, 435);
|
|
|
|
|
//LineTo(hdc, 670, 435);
|
|
|
|
|
//MoveToEx(hdc, 670, 553, NULL);
|
|
|
|
|
//LineTo(hdc, 790, 530);
|
|
|
|
|
//LineTo(hdc, 790, 420);
|
|
|
|
|
//LineTo(hdc, 670, 435);
|
|
|
|
|
//MoveToEx(hdc, 580, 553, NULL);
|
|
|
|
|
//LineTo(hdc, 580, 480);
|
|
|
|
|
//LineTo(hdc, 490, 480);
|
|
|
|
|
//LineTo(hdc, 490, 553);
|
|
|
|
|
//MoveToEx(hdc, 535, 553, NULL);
|
|
|
|
|
//LineTo(hdc, 535, 480);
|
|
|
|
|
//LineTo(hdc, 580,553);
|
|
|
|
|
//MoveToEx(hdc, 535, 480, NULL);
|
|
|
|
|
//LineTo(hdc, 490, 553);
|
|
|
|
|
//hPen = CreatePen(PS_SOLID, 4, RGB(165, 42, 42));
|
|
|
|
|
//SelectObject(hdc, hPen);
|
|
|
|
|
//MoveToEx(hdc, 290, 490, NULL);
|
|
|
|
|
//LineTo(hdc, 290, 410);
|
|
|
|
|
//LineTo(hdc, 190, 400);
|
|
|
|
|
//LineTo(hdc, 190, 440);
|
|
|
|
|
//LineTo(hdc, 290, 450);
|
|
|
|
|
//LineTo(hdc, 240, 480);
|
|
|
|
|
//LineTo(hdc, 155, 465);
|
|
|
|
|
//LineTo(hdc, 190, 440);
|
|
|
|
|
//MoveToEx(hdc, 240, 480, NULL);
|
|
|
|
|
//LineTo(hdc, 240, 520);
|
|
|
|
|
//MoveToEx(hdc, 155, 465, NULL);
|
|
|
|
|
//LineTo(hdc, 155, 500);
|
|
|
|
|
//hBrush = CreateHatchBrush(HS_CROSS, RGB(0, 0, 0));
|
|
|
|
|
//SelectObject(hdc, hBrush);
|
|
|
|
|
////pikap
|
|
|
|
|
//MoveToEx(hdc, 620, 200, NULL);
|
|
|
|
|
//LineTo(hdc, 620, 150);
|
|
|
|
|
//LineTo(hdc, 680, 130);
|
|
|
|
|
//LineTo(hdc, 710, 100);
|
|
|
|
|
//LineTo(hdc, 760, 100);
|
|
|
|
|
//LineTo(hdc, 760, 150);
|
|
|
|
|
//LineTo(hdc, 880, 150);
|
|
|
|
|
//LineTo(hdc, 880, 200);
|
|
|
|
|
//LineTo(hdc, 820, 200);
|
|
|
|
|
//Arc(hdc, 765, 160, 820, 220, 860, 220, 460, 300);
|
|
|
|
|
//MoveToEx(hdc, 765, 200, NULL);
|
|
|
|
|
//LineTo(hdc, 720, 200);
|
|
|
|
|
//Arc(hdc, 665, 160, 720, 220, 760, 220, 360, 300);
|
|
|
|
|
//MoveToEx(hdc, 665, 200, NULL);
|
|
|
|
|
//LineTo(hdc, 620, 200);
|
|
|
|
|
//Ellipse(hdc, 667, 165, 717, 225);
|
|
|
|
|
//Ellipse(hdc, 767, 165, 817, 225);
|
|
|
|
|
//hBrush = CreateSolidBrush(RGB(0, 0, 10));
|
|
|
|
|
//SelectObject(hdc, hBrush);
|
|
|
|
|
//RECT rect = { 990, 30, 1070, 177 };
|
|
|
|
|
//FillRect(hdc, &rect, hBrush);
|
|
|
|
|
//rect = { 1071, 85, 1270, 177 };
|
|
|
|
|
//FillRect(hdc, &rect, hBrush);
|
|
|
|
|
//hBrush = CreateSolidBrush(RGB(220, 20, 60));
|
|
|
|
|
//rect = { 1120, 15, 1150, 87 };
|
|
|
|
|
//FillRect(hdc, &rect, hBrush);
|
|
|
|
|
//hBrush = CreateSolidBrush(RGB(0, 0, 91));
|
|
|
|
|
//SelectObject(hdc, hBrush);
|
|
|
|
|
//Ellipse(hdc, 1020, 177, 1070, 237);
|
|
|
|
|
//Ellipse(hdc, 1170, 177, 1220, 237);
|
|
|
|
|
//hBrush = CreateSolidBrush( RGB(153, 153, 253));
|
|
|
|
|
//SelectObject(hdc, hBrush);
|
|
|
|
|
//hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
|
|
|
|
|
//SelectObject(hdc, hPen);
|
|
|
|
|
//Ellipse(hdc, 40, 10, 240, 100);
|
|
|
|
|
//Ellipse(hdc, 250, 40, 460, 140);
|
|
|
|
|
//Ellipse(hdc, 470, 5, 730, 95);
|
|
|
|
|
void Mercedes(HDC); {
|
|
|
|
|
Ellipse(hdc, 0, 0, 190, 190);
|
|
|
|
|
MoveToEx(hdc, 100, 0, NULL);
|
|
|
|
|
LineTo(hdc, 85, 85);
|
|
|
|
|
LineTo(hdc, 6, 140);
|
|
|
|
|
LineTo(hdc, 85, 115);
|
|
|
|
|
LineTo(hdc, 180, 140);
|
|
|
|
|
LineTo(hdc, 110, 85);
|
|
|
|
|
LineTo(hdc, 100, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|