-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.cpp
More file actions
113 lines (97 loc) · 3.33 KB
/
generator.cpp
File metadata and controls
113 lines (97 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "generator.h"
#include "generator.rh"
INT_PTR CALLBACK Gener(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
int nPoint = 0;
int xMin = 0;
int xMax = 0;
int yMin = 0;
int yMax = 0;
try
{
nPoint = (int)round(stod(Generator::GetBoxText(hDlg, IDC_NPOINT)));
xMin = (int)round(stod(Generator::GetBoxText(hDlg, IDC_XMIN)));
xMax = (int)round(stod(Generator::GetBoxText(hDlg, IDC_XMAX)));
yMin = (int)round(stod(Generator::GetBoxText(hDlg, IDC_YMIN)));
yMax = (int)round(stod(Generator::GetBoxText(hDlg, IDC_YMAX)));
}
catch (...)
{
MessageBox(hDlg, L"Íåïðàâèëüíèé ôîðìàò", L"Ïîìèëêà", MB_OK | MB_ICONERROR);
break;
}
if (nPoint < 2 || nPoint > 30)
{
MessageBox(hDlg, L"ê³ëüê³ñòü òî÷îê ïîâèííà áóòè â³ä 2 äî 30", L"Ñïðîáóéòå ùå", MB_OK | MB_ICONERROR);
break;
}
if (abs(xMin) > 240 || abs(xMax) > 240 || abs(yMin) > 240 || abs(yMax) > 240)
{
MessageBox(hDlg, L"êîîðäèíàòè ïîâèíí³ áóòè çà ìîäóëåì íå á³ëüøå 240", L"Ñïðîáóéòå ùå", MB_OK | MB_ICONERROR);
break;
}
if (xMin > xMax || yMin > yMax)
{
MessageBox(hDlg, L"Íåïðàâèëüíî ââåäåí³ äàí³(min áûëüøå çà max)", L"Ñïðîáóéòå ùå", MB_OK | MB_ICONERROR);
break;
}
HWND hWnd2 = FindWindow(L"OBJECT2", NULL);
if (!hWnd2)
{
WinExec("Object2.exe", SW_SHOW);
hWnd2 = FindWindow(L"OBJECT2", NULL);
}
int data[5] = { nPoint, xMin, xMax, yMin, yMax };
Generator::SendData(hWnd2, GetParent(hDlg), data, sizeof(data));
HWND hWnd3 = FindWindow(L"OBJECT3", NULL);
if (!hWnd3)
{
WinExec("Object3.exe", SW_SHOW);
hWnd3 = FindWindow(L"OBJECT3", NULL);
}
PostMessage(hWnd3, WM_CLIPBOARDUPDATE, NULL, NULL);
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
if (LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
Generator::Generator(void) {}
std::wstring Generator::GetBoxText(HWND hWnd, int boxID)
{
WCHAR buff[8];
GetWindowText(GetDlgItem(hWnd, boxID), buff, 8);
return buff;
}
void Generator::SendData(HWND hWndDest, HWND hWndSrc, void* lp, long cb)
{
COPYDATASTRUCT cds;
cds.dwData = 1;
cds.cbData = cb;
cds.lpData = lp;
SendMessage(hWndDest, WM_COPYDATA, (WPARAM)hWndSrc, (LPARAM)&cds);
}
void Generator::Start(HINSTANCE hInst, HWND hWnd)
{
DialogBox(hInst, MAKEINTRESOURCE(IDD_GENERATOR), hWnd, Gener);
}
void Generator::Close()
{
HWND hWnd2 = FindWindow(L"OBJECT2", NULL);
HWND hWnd3 = FindWindow(L"OBJECT3", NULL);
if (hWnd2) PostMessage(hWnd2, WM_DESTROY, NULL, NULL);
if (hWnd3) PostMessage(hWnd3, WM_DESTROY, NULL, NULL);
}