Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\back\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- #pragma once
- #include "framework.h"
- #include <math.h>
- struct Circle
- {
- int x0, y0, r;
- Circle() {};
- Circle(int x, int y, int rr)
- {
- x0 = x;
- y0 = y;
- r = rr;
- }
- void PaintC(HDC hdc, int g1, int g2);
- };
- struct Line
- {
- int x1, x2, y1, y2;
- Line() {};
- Line(int x, int xx, int y, int yy)
- {
- x1 = x;
- x2 = xx;
- y1 = y;
- y2 = yy;
- }
- void PaintL(HDC hdc, int g1, int g2);
- };
- class Plate {
- private:
- double Len(int x, int xx, int y, int yy);
- public:
- Circle c[100];
- Line l[100];
- int nl, nc;
- Plate();
- int AddCircle(int x, int y, int r);
- int AddLine(int x, int xx, int y, int yy);
- int DelCircle(int x, int y, int r);
- int DelLine(int x, int xx, int y, int yy);
- int Usl();
- int Cond1();
- double Cond2();
- void PaintP(HDC hdc, int g1, int g2);
- };
- void Circle::PaintC(HDC hdc, int g1, int g2)
- {
- Arc(hdc, x0 - r + g1, -y0 + r + g2, x0 + r + g1, -y0 - r + g2, x0 - r + g1, -y0 + r + g2, x0 - r + g1, -y0 + r + g2);
- HPEN Punktir = CreatePen(PS_DOT, 1, RGB(169, 169, 169));
- SelectObject(hdc, Punktir);
- MoveToEx(hdc, g1, -y0 + g2, NULL);
- LineTo(hdc, x0 + g1, -y0 + g2);
- MoveToEx(hdc, x0 + g1, -y0 + g2, NULL);
- LineTo(hdc, x0 + g1, g2);
- char buf[10];
- _ltoa_s(x0, buf, 10);
- int i = -1;
- while (buf[i + 1] != '\0')
- i++;
- TextOutA(hdc, g1 + x0, g2 + 2, buf, i + 1);
- _ltoa_s(y0, buf, 10);
- i = -1;
- while (buf[i + 1] != '\0')
- i++;
- TextOutA(hdc, g1 + 2, g2 - y0, buf, i + 1);
- HPEN Norm = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
- SelectObject(hdc, Norm);
- }
- void Line::PaintL(HDC hdc, int g1, int g2)
- {
- HPEN Punktir = CreatePen(PS_DOT, 1, RGB(169, 169, 169));
- SelectObject(hdc, Punktir);
- MoveToEx(hdc, g1, -y1 + g2, NULL);
- LineTo(hdc, x1 + g1, -y1 + g2);
- MoveToEx(hdc, x1 + g1, -y1 + g2, NULL);
- LineTo(hdc, x1 + g1, g2);
- MoveToEx(hdc, g1, -y2 + g2, NULL);
- LineTo(hdc, x2 + g1, -y2 + g2);
- MoveToEx(hdc, x2 + g1, -y2 + g2, NULL);
- LineTo(hdc, x2 + g1, g2);
- HPEN Norm = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
- SelectObject(hdc, Norm);
- MoveToEx(hdc, x1 + g1, -y1 + g2, NULL);
- LineTo(hdc, x2 + g1, -y2 + g2);
- char buf[10];
- _ltoa_s(x1, buf, 10);
- int i = -1;
- while (buf[i + 1] != '\0')
- i++;
- TextOutA(hdc, g1 + x1, g2 + 2, buf, i + 1);
- _ltoa_s(x2, buf, 10);
- i = -1;
- while (buf[i + 1] != '\0')
- i++;
- TextOutA(hdc, g1 + x2, g2 + 2, buf, i + 1);
- _ltoa_s(y1, buf, 10);
- i = -1;
- while (buf[i + 1] != '\0')
- i++;
- TextOutA(hdc, g1 + 2, g2 - y1, buf, i + 1);
- _ltoa_s(y2, buf, 10);
- i = -1;
- while (buf[i + 1] != '\0')
- i++;
- TextOutA(hdc, g1 + 2, g2 - y2, buf, i + 1);
- }
- void Plate::PaintP(HDC hdc, int g1, int g2)
- {
- HFONT Font = CreateFont(15, 5, 0, 0, 1, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, L"Arial Bold");
- HFONT Font1 = CreateFont(15, 5, 0, 0, 600, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, L"Arial Bold");
- SelectObject(hdc, Font1);
- char buf[10];
- int j = -1;
- TextOutA(hdc, g1 * 2 + 4, 2, "Окружности", 11);
- TextOutA(hdc, g1 * 2 + 184, 2, "Отрезки", 8);
- TextOutA(hdc, g1 * 2 + 4, 32, "x0", 2);
- TextOutA(hdc, g1 * 2 + 64, 32, "y0", 2);
- TextOutA(hdc, g1 * 2 + 124, 32, "r", 2);
- TextOutA(hdc, g1 * 2 + 184, 32, "x1", 2);
- TextOutA(hdc, g1 * 2 + 244, 32, "y1", 2);
- TextOutA(hdc, g1 * 2 + 304, 32, "x2", 2);
- TextOutA(hdc, g1 * 2 + 364, 32, "y2", 2);
- SelectObject(hdc, Font);
- for (int i = 0; i < nc; i++)
- {
- c[i].PaintC(hdc, g1, g2);
- _ltoa_s(c[i].x0, buf, 10);
- j = -1;
- while (buf[j + 1] != '\0')
- j++;
- TextOutA(hdc, g1 * 2 + 4, i * 20 + 62, buf, j + 1);
- _ltoa_s(c[i].y0, buf, 10);
- j = -1;
- while (buf[j + 1] != '\0')
- j++;
- TextOutA(hdc, g1 * 2 + 64, i * 20 + 62, buf, j + 1);
- _ltoa_s(c[i].r, buf, 10);
- j = -1;
- while (buf[j + 1] != '\0')
- j++;
- TextOutA(hdc, g1 * 2 + 124, i * 20 + 62, buf, j + 1);
- }
- for (int i = 0; i < nl; i++)
- {
- l[i].PaintL(hdc, g1, g2);
- _ltoa_s(l[i].x1, buf, 10);
- j = -1;
- while (buf[j + 1] != '\0')
- j++;
- TextOutA(hdc, g1 * 2 + 184, i * 20 + 62, buf, j + 1);
- _ltoa_s(l[i].y1, buf, 10);
- j = -1;
- while (buf[j + 1] != '\0')
- j++;
- TextOutA(hdc, g1 * 2 + 244, i * 20 + 62, buf, j + 1);
- _ltoa_s(l[i].x2, buf, 10);
- j = -1;
- while (buf[j + 1] != '\0')
- j++;
- TextOutA(hdc, g1 * 2 + 304, i * 20 + 62, buf, j + 1);
- _ltoa_s(l[i].y2, buf, 10);
- j = -1;
- while (buf[j + 1] != '\0')
- j++;
- TextOutA(hdc, g1 * 2 + 364, i * 20 + 62, buf, j + 1);
- }
- SelectObject(hdc, Font);
- }
- Plate::Plate()
- {
- nl = 0;
- nc = 0;
- }
- int Plate::AddCircle(int x, int y, int rr)
- {
- int fl = 0;
- if (nc < 100)
- {
- int i = 0;
- while (i < nc && !fl)
- {
- if (c[i].x0 == x && c[i].y0 == y && c[i].r == rr)
- fl = 1;
- i++;
- }
- if (!fl)
- {
- fl = 1;
- nc++;
- c[nc - 1].x0 = x;
- c[nc - 1].y0 = y;
- c[nc - 1].r = rr;
- }
- }
- return fl;
- }
- int Plate::AddLine(int x, int xx, int y, int yy)
- {
- int fl = 0;
- if (nl < 100)
- {
- int i = 0;
- while (i < nl && !fl)
- {
- if (l[i].x1 == x && l[i].y1 == y && l[i].x2 == xx && l[i].y2 == yy)
- fl = 1;
- i++;
- }
- if (!fl)
- {
- fl = 1;
- nl++;
- l[nl - 1].x1 = x;
- l[nl - 1].x2 = xx;
- l[nl - 1].y1 = y;
- l[nl - 1].y2 = yy;
- }
- }
- return fl;
- }
- int Plate::DelCircle(int x, int y, int rr)
- {
- int fl = 0;
- if (nc > 0)
- {
- int i = 0;
- while (i < nc && !fl)
- {
- if (c[i].x0 == x && c[i].y0 == y && c[i].r == rr)
- fl = 1;
- i++;
- }
- if (fl) {
- for (int j = i; j < nc; j++)
- c[j - 1] = c[j];
- nc--;
- }
- }
- return fl;
- }
- int Plate::DelLine(int x, int xx, int y, int yy)
- {
- int fl = 0;
- int i = 0;
- if (nl > 0)
- {
- while (i < nl && !fl)
- {
- if (l[i].x1 == x && l[i].y1 == y && l[i].x2 == xx && l[i].y2 == yy)
- fl = 1;
- i++;
- }
- if (fl) {
- for (int j = i; j < nl; j++)
- l[j - 1] = l[j];
- nl--;
- }
- }
- return fl;
- }
- double Plate::Len(int x, int xx, int y, int yy) {
- return sqrt(pow(x - xx, 2) + pow(y - yy, 2));
- }
- int Plate::Usl() {
- int fl = 1;
- for (int i = 0; i < nc && fl; i++) {
- if (c[i].x0 + c[i].r > 0 || c[i].y0 + c[i].r > 0) {
- fl = 0;
- }
- }
- return fl;
- }
- int Plate::Cond1() {
- double len = Len(c[0].x0, 0, c[0].y0, 0);
- int k = 0;
- for (int i = 1; i < nc; i++) {
- if (Len(c[i].x0, 0, c[i].y0, 0) < len) {
- len = Len(c[i].x0, 0, c[i].y0, 0);
- k = i;
- }
- }
- return k;
- }
- double Plate::Cond2() {
- double len = 0;
- for (int i = 0; i < nl; i++) {
- len += Len(l[i].x1, l[i].x2, l[i].y1, l[i].y2);
- }
- return len;
- }
- /////////////////////////////////////////Основная/////////////////////////////////////////////////
- // WindowsProject1.cpp : Defines the entry point for the application.
- //
- #include "framework.h"
- #include "WindowsProject1.h"
- #include "back.h"
- #include <iostream>
- #include <Commdlg.h>
- #define MAX_LOADSTRING 100
- Plate P;
- int rez = -1;
- // Global Variables:
- HINSTANCE hInst; // current instance
- WCHAR szTitle[MAX_LOADSTRING]; // The title bar text
- WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
- // Forward declarations of functions included in this code module:
- ATOM MyRegisterClass(HINSTANCE hInstance);
- BOOL InitInstance(HINSTANCE, int);
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
- INT_PTR CALLBACK Circ(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
- INT_PTR CALLBACK Lin(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
- INT_PTR CALLBACK DelCirc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
- INT_PTR CALLBACK DelLin(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
- int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
- _In_opt_ HINSTANCE hPrevInstance,
- _In_ LPWSTR lpCmdLine,
- _In_ int nCmdShow)
- {
- UNREFERENCED_PARAMETER(hPrevInstance);
- UNREFERENCED_PARAMETER(lpCmdLine);
- // TODO: Place code here.
- // Initialize global strings
- LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
- LoadStringW(hInstance, IDC_WINDOWSPROJECT1, szWindowClass, MAX_LOADSTRING);
- MyRegisterClass(hInstance);
- // Perform application initialization:
- if (!InitInstance (hInstance, nCmdShow))
- {
- return FALSE;
- }
- HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WINDOWSPROJECT1));
- MSG msg;
- // Main message loop:
- while (GetMessage(&msg, nullptr, 0, 0))
- {
- if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- return (int) msg.wParam;
- }
- //
- // FUNCTION: MyRegisterClass()
- //
- // PURPOSE: Registers the window class.
- //
- 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_WINDOWSPROJECT1));
- wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
- wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_WINDOWSPROJECT1);
- wcex.lpszClassName = szWindowClass;
- wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
- return RegisterClassExW(&wcex);
- }
- //
- // FUNCTION: InitInstance(HINSTANCE, int)
- //
- // PURPOSE: Saves instance handle and creates main window
- //
- // COMMENTS:
- //
- // In this function, we save the instance handle in a global variable and
- // create and display the main program window.
- //
- BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
- {
- hInst = hInstance; // Store instance handle in our global variable
- 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;
- }
- //
- // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
- //
- // PURPOSE: Processes messages for the main window.
- //
- // WM_COMMAND - process the application menu
- // WM_PAINT - Paint the main window
- // WM_DESTROY - post a quit message and return
- //
- //
- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message)
- {
- case WM_COMMAND:
- {
- int wmId = LOWORD(wParam);
- // Parse the menu selections:
- switch (wmId)
- {
- case IDM_EXIT:
- DestroyWindow(hWnd);
- break;
- case IDM_LOAD:
- {
- rez = -1;
- wchar_t wfname[300] = L"";
- OPENFILENAME ofn;
- size_t i;
- memset(&ofn, 0, sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hWnd;
- ofn.lpstrFile = wfname;
- ofn.nMaxFile = 300;
- ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
- if (GetOpenFileName(&ofn) == 0) {
- break;
- }
- char fname[300];
- wcstombs_s(&i, fname, wfname, 100);
- FILE* f;
- fopen_s(&f, fname, "rt");
- if (f == NULL) {
- break;
- }
- char buf[100];
- int x, y, r;
- int x1, y1, x2, y2;
- P.nc = 0;
- P.nl = 0;
- int nc, nl;
- fgets(buf, 100, f);
- sscanf_s(buf, "%d", &nc);
- //P.nc = nc;
- for (int i = 0; i < nc; i++)
- {
- fgets(buf, 100, f);
- sscanf_s(buf, "%d%d%d", &x, &y, &r);
- P.AddCircle(x, y, r);
- }
- fgets(buf, 100, f);
- sscanf_s(buf, "%d", &nl);
- //P.nl = nl;
- for (int i = 0; i < nl; i++) {
- fgets(buf, 100, f);
- sscanf_s(buf, "%d%d%d%d", &x1, &y1, &x2, &y2);
- P.AddLine(x1, x2, y1, y2);
- }
- fclose(f);
- InvalidateRect(hWnd, NULL, TRUE);
- }
- break;
- case IDM_ADDCIRCLE:
- {
- rez = -1;
- DialogBox(hInst, MAKEINTRESOURCE(IDD_ADDCIRCLE), hWnd, Circ);
- InvalidateRect(hWnd, NULL, TRUE);
- }
- break;
- case IDM_ADDLINE:
- {
- rez = -1;
- DialogBox(hInst, MAKEINTRESOURCE(IDD_ADDLINE), hWnd, Lin);
- InvalidateRect(hWnd, NULL, TRUE);
- }
- break;
- case IDM_DELETECIRCLE:
- {
- rez = -1;
- DialogBox(hInst, MAKEINTRESOURCE(IDD_DELCIRCLE), hWnd, DelCirc);
- InvalidateRect(hWnd, NULL, TRUE);
- }
- break;
- case IDM_DELETELINE:
- {
- rez = -1;
- DialogBox(hInst, MAKEINTRESOURCE(IDD_DELLINE), hWnd, DelLin);
- InvalidateRect(hWnd, NULL, TRUE);
- }
- break;
- case IDM_SAVE:
- {
- wchar_t wfname[300] = L"";
- OPENFILENAME ofn;
- size_t i;
- memset(&ofn, 0, sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hWnd;
- ofn.lpstrFile = wfname;
- ofn.nMaxFile = 300;
- ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
- if (GetSaveFileName(&ofn) == 0) {
- break;
- }
- char fname[300];
- wcstombs_s(&i, fname, wfname, 100);
- strcat_s(fname, ".txt");
- FILE* f;
- fopen_s(&f, fname, "w+");
- if (f == NULL) {
- break;
- }
- fprintf_s(f, "%i", P.nc);
- fprintf_s(f, "\n");
- for (int i = 0; i < P.nc; i++)
- {
- fprintf_s(f, "%i", P.c[i].x0);
- fprintf_s(f, " ");
- fprintf_s(f, "%i", P.c[i].y0);
- fprintf_s(f, " ");
- fprintf_s(f, "%i", P.c[i].r);
- fprintf_s(f, "\n");
- }
- fprintf_s(f, "%i", P.nl);
- fprintf_s(f, "\n");
- for (int i = 0; i < P.nl; i++)
- {
- fprintf_s(f, "%i", P.l[i].x1);
- fprintf_s(f, " ");
- fprintf_s(f, "%i", P.l[i].y1);
- fprintf_s(f, " ");
- fprintf_s(f, "%i", P.l[i].x2);
- fprintf_s(f, " ");
- fprintf_s(f, "%i", P.l[i].y2);
- fprintf_s(f, "\n");
- }
- fclose(f);
- InvalidateRect(hWnd, NULL, TRUE);
- }
- break;
- case IDM_USL:
- {
- char s1[200] = "Задано множество окружностей и отрезков. Если не все окружности лежат в 3 четверти, то найти окружность, центр которой наименее удалён от начала координат, иначе найти сумму длин отрезков.";
- MessageBoxA(hWnd, s1, "Условие:", MB_OK);
- }
- break;
- case IDM_RESH:
- {
- rez = P.Usl();
- if (rez == 1) {
- double k = P.Cond2();
- char s1[100] = "Сумма длин отрезков: ";
- char s2[30];
- int i = 1;
- while (k / pow(10, i) > 1)
- i++;
- int t = int(k);
- sprintf_s(s2, "%i", t);
- strcat_s(s1, s2);
- strcat_s(s1, ".");
- t = int((int(round(k* 1000))%int(pow(10,i))));
- sprintf_s(s2, "%i", t);
- strcat_s(s1, s2);
- MessageBoxA(hWnd, s1, "Решение:", MB_OK);
- }
- InvalidateRect(hWnd, NULL, TRUE);
- }
- break;
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- }
- break;
- case WM_PAINT:
- {
- HPEN Norm = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
- HPEN Res = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
- HFONT Font = CreateFont(15, 10, 0, 0, 1, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, L"Arial Bold");
- HBRUSH Brush = CreateSolidBrush(RGB(255, 255, 255));
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(hWnd, &ps);
- RECT rect;
- SelectObject(hdc, Brush);
- GetClientRect(hWnd, &rect);
- SelectObject(hdc, Norm);
- Rectangle(hdc, 0, 0, rect.right, rect.bottom);
- SelectObject(hdc, Norm);
- P.PaintP(hdc, (rect.right - 400) / 2, rect.bottom / 2);
- SelectObject(hdc, Norm);
- SelectObject(hdc, Font);
- MoveToEx(hdc, rect.right - 400, rect.bottom / 2, NULL);
- LineTo(hdc, 0, rect.bottom / 2);
- MoveToEx(hdc, rect.right - 400, rect.bottom / 2, NULL);
- LineTo(hdc, rect.right - 410, rect.bottom / 2 + 10);
- MoveToEx(hdc, rect.right - 400, rect.bottom / 2, NULL);
- LineTo(hdc, rect.right - 410, rect.bottom / 2 - 10);
- TextOutA(hdc, rect.right - 405, rect.bottom / 2 + 5, "x", 1);
- MoveToEx(hdc, (rect.right - 400) / 2, 0, NULL);
- LineTo(hdc, (rect.right - 400) / 2, rect.bottom);
- MoveToEx(hdc, (rect.right - 400) / 2, 0, NULL);
- LineTo(hdc, (rect.right - 400) / 2 + 10, 10);
- MoveToEx(hdc, (rect.right - 400) / 2, 0, NULL);
- LineTo(hdc, (rect.right - 400) / 2 - 10, 10);
- TextOutA(hdc, (rect.right - 400) / 2 - 15, 2, "y", 1);
- if (rez == 0) {
- SelectObject(hdc, Res);
- P.c[P.Cond1()].PaintC(hdc, (rect.right - 400) / 2, rect.bottom / 2);
- //SelectObject(hdc, Norm);
- }
- // TODO: Add any drawing code that uses hdc here...
- EndPaint(hWnd, &ps);
- }
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- return 0;
- }
- // Message handler for about box.
- 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;
- }
- INT_PTR CALLBACK Circ(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)
- {
- TCHAR tmp1[5], tmp2[5], tmp3[5];
- GetDlgItemText(hDlg, IDC_x0, tmp1, 5);
- GetDlgItemText(hDlg, IDC_y0, tmp2, 5);
- GetDlgItemText(hDlg, IDC_r, tmp3, 5);
- P.AddCircle(_tstof(tmp1), _tstof(tmp2), _tstof(tmp3));
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- else if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- break;
- }
- return (INT_PTR)FALSE;
- }
- INT_PTR CALLBACK Lin(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)
- {
- TCHAR tmp1[5], tmp2[5], tmp3[5], tmp4[5];
- GetDlgItemText(hDlg, IDC_xx1, tmp1, 5);
- GetDlgItemText(hDlg, IDC_yy1, tmp2, 5);
- GetDlgItemText(hDlg, IDC_xx2, tmp3, 5);
- GetDlgItemText(hDlg, IDC_yy2, tmp4, 5);
- P.AddLine(_tstof(tmp1), _tstof(tmp3), _tstof(tmp2), _tstof(tmp4));
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- else
- if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- break;
- }
- return (INT_PTR)FALSE;
- }
- INT_PTR CALLBACK DelCirc(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)
- {
- TCHAR tmp1[5], tmp2[5], tmp3[5];
- GetDlgItemText(hDlg, IDC_x0, tmp1, 5);
- GetDlgItemText(hDlg, IDC_y0, tmp2, 5);
- GetDlgItemText(hDlg, IDC_r, tmp3, 5);
- P.DelCircle(_tstof(tmp1), _tstof(tmp2), _tstof(tmp3));
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- else if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- break;
- }
- return (INT_PTR)FALSE;
- }
- INT_PTR CALLBACK DelLin(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)
- {
- TCHAR tmp1[5], tmp2[5], tmp3[5], tmp4[5];
- GetDlgItemText(hDlg, IDC_xx1, tmp1, 5);
- GetDlgItemText(hDlg, IDC_yy1, tmp2, 5);
- GetDlgItemText(hDlg, IDC_xx2, tmp3, 5);
- GetDlgItemText(hDlg, IDC_yy2, tmp4, 5);
- P.DelLine(_tstof(tmp1), _tstof(tmp3), _tstof(tmp2), _tstof(tmp4));
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- else
- if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- break;
- }
- return (INT_PTR)FALSE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement