-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTabParameters.c
More file actions
158 lines (140 loc) · 4.13 KB
/
TabParameters.c
File metadata and controls
158 lines (140 loc) · 4.13 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include "TabParameters.h"
static HFONT hFont;
static HWND hWndParametersDataGrid;
static short * PRM_orig;
static short * PRM_cur;
static short * PRM_set;
DWORD WINAPI AddRemainingParameters(int rtm)
{
char temp[3][32];
int i;
Sleep(250);
for (int prm = rtm; prm < PRM_MAX; ++prm)
{
strcpy_s(temp[0], 32, PRM_code[prm]);
sprintf_s(temp[1], 32, "%d", PRM[prm]);
DataGridView_AddRow(hWndParametersDataGrid, (LPSTR)temp, 2);
}
return 0;
}
LRESULT CALLBACK WindowProcTabParameters(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
RECT rect, rect2;
char temp[3][32];
int i, row, col;
switch (uMsg)
{
case WM_CREATE:
GetClientRect(hWnd, &rect);
hWndParametersDataGrid = CreateWindowEx((DWORD)NULL, "DGridVwClass",
"Parameters",
WS_CHILD, rect.left, rect.top, rect.right - rect.left - 6, rect.bottom - 6, hWnd, NULL, hMainInstance, tabPRM_ischanged);
DataGridView_AddColumn(hWndParametersDataGrid, 1, 150, (LPSTR)"Parameters");
DataGridView_AddColumn(hWndParametersDataGrid, 2, 75, (LPSTR)"Instelling");
PRM_orig = malloc(sizeof(short) * PRM_MAX);
PRM_cur = malloc(sizeof(short) * PRM_MAX);
PRM_set = malloc(sizeof(short) * PRM_MAX);
int prm = 0;
for (prm = 0; prm < PRM_MAX; ++prm)
{
PRM_orig[prm] = PRM[prm];
PRM_cur[prm] = PRM[prm];
PRM_set[prm] = 0;
}
for (prm = 0; prm < PRM_MAX; ++prm)
{
strcpy_s(temp[0], 32, PRM_code[prm]);
sprintf_s(temp[1], 32, "%d", PRM[prm]);
DataGridView_AddRow(hWndParametersDataGrid, (LPSTR)temp, 2);
ListView_GetItemRect(hWndParametersDataGrid, prm, &rect2, LVIR_BOUNDS);
if (rect2.bottom >= rect.bottom - 6) break;
}
HANDLE thread = CreateThread(
NULL, // default security attributes
0, // use default stack size
AddRemainingParameters, // thread function name
prm + 1, // argument to thread function
0, // use default creation flags
NULL); // returns the thread identifier
DataGridView_DisplayRowHeaders(hWndParametersDataGrid, TRUE);
DataGridView_ExtendLastColumn(hWndParametersDataGrid, TRUE, 400, 100);
DataGridView_SetResizableHeader(hWndParametersDataGrid, 1);
return 0;
case MIRMSG_TABCHANGE:
switch (wParam)
{
case SW_SHOW:
ShowWindow(hWndParametersDataGrid, SW_SHOW);
break;
}
return 0;
case WM_SIZE:
GetClientRect(hMainTab, &rect);
TabCtrl_AdjustRect(hMainTab, 0, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
SetWindowPos(hWnd, HWND_TOP, rect.left, rect.top, width, height, SWP_NOACTIVATE);
GetClientRect(hWnd, &rect);
if (hWndParametersDataGrid)
{
SendMessage(hWndParametersDataGrid, WM_SIZE, (WPARAM)SIZE_RESTORED, MAKELPARAM(rect.right - rect.left - 6, rect.bottom - rect.top - 6));
InvalidateRect(hMainTab, &rect, TRUE);
}
break;
case WM_COMMAND:
switch (HIWORD(wParam))
{
case DGVM_ENDEDIT:
col = HIWORD(lParam);
row = LOWORD(lParam);
if (col != 1) return 1;
DataGridView_GetCellValue(hWndParametersDataGrid, row, col, temp[0], 32);
for (i = 0; i < strlen(temp[0]); i++)
{
if (temp[0][i] >= 0 && temp[0][i] <= 255 && !isdigit(temp[0][i]))
{
PRM_set[row] = 2;
return 1;
}
}
PRM_cur[row] = PRM[row] = atoi(temp[0]);
PRM_set[row] = (atoi(temp[0]) != PRM_orig[row]) ? 1 : 0;
return 1;
}
break;
case WM_DESTROY:
free(PRM_orig);
free(PRM_cur);
free(PRM_set);
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
void TabParametersUpdate()
{
RECT rect;
if (CIF_PARM1WIJZPB != -1 || CIF_PARM1WIJZAP != -1 ||
CIF_PARM2WIJZPB != -1 || CIF_PARM2WIJZAP != -1)
{
for (int prm = 0; prm < PRM_MAX; ++prm)
{
if (PRM_cur[prm] != PRM[prm])
{
char temp[32];
PRM_cur[prm] = PRM[prm];
PRM_set[prm] = (PRM[prm] != PRM_orig[prm]) ? 1 : 0;
sprintf_s(temp, 32, "%d", PRM[prm]);
DataGridView_SetCellValue(hWndParametersDataGrid, prm, 1, temp);
ListView_GetItemRect(hWndParametersDataGrid, prm, &rect, LVIR_BOUNDS);
InvalidateRect(hWndParametersDataGrid, &rect, TRUE);
}
}
}
}
void TabParametersReset()
{
}
short CALLBACK tabPRM_ischanged(int prm)
{
return PRM_set[prm];
}