Skip to content

Commit 8b2bd21

Browse files
committed
优化 捕获面板逻辑
1 parent eb9cafe commit 8b2bd21

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

MateBook-E-Pen.cpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ INT_PTR CALLBACK popup(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
248248
case WM_COMMAND:
249249
if (HIWORD(wParam) == LBN_SELCHANGE)
250250
{
251-
capturing_WnE = -5;
251+
if (capturing_WnE == -4) capturing_WnE = -5;
252+
else if (capturing_WnE == -6) capturing_WnE = -7;
252253
EnableWindow(GetDlgItem(hDlg, IDC_TEST), TRUE);
253254
break;
254255
}
@@ -268,6 +269,17 @@ INT_PTR CALLBACK popup(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
268269
ShowWindow(GetDlgItem(hDlg, IDC_ERASER), SW_SHOW);
269270
capturing_WnE = 0;
270271
}
272+
if (capturing_WnE == -6 || capturing_WnE == -7)
273+
{
274+
ShowWindow(GetDlgItem(hDlg, IDC_LIST1), SW_HIDE);
275+
ShowWindow(GetDlgItem(hDlg, IDC_S7), SW_SHOW);
276+
ShowWindow(GetDlgItem(hDlg, IDC_S8), SW_SHOW);
277+
ShowWindow(GetDlgItem(hDlg, IDC_S9), SW_SHOW);
278+
ShowWindow(GetDlgItem(hDlg, IDC_WINDOW), SW_SHOW);
279+
ShowWindow(GetDlgItem(hDlg, IDC_PEN), SW_SHOW);
280+
ShowWindow(GetDlgItem(hDlg, IDC_ERASER), SW_SHOW);
281+
capturing_WnE = -1;
282+
}
271283
EnableWindow(GetDlgItem(hDlg, IDC_SAVE), FALSE);
272284
EnableWindow(GetDlgItem(hDlg, IDC_START), FALSE);
273285
EnableWindow(GetDlgItem(hDlg, IDC_TEST), FALSE);
@@ -293,8 +305,8 @@ INT_PTR CALLBACK popup(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
293305
}
294306
case IDC_TEST:
295307
{
296-
if (capturing_WnE == 4) capturing_WnE = 5;
297-
else if (capturing_WnE == -5)
308+
if (capturing_WnE == 4 || capturing_WnE == 6) capturing_WnE = 5;
309+
else if (capturing_WnE == -5 || capturing_WnE == -7)
298310
{
299311
int index = SendMessage(GetDlgItem(hDlg, IDC_LIST1), LB_GETCURSEL, 0, 0);
300312
SendMessage(GetDlgItem(hDlg, IDC_LIST1), LB_DELETESTRING, index, 0);
@@ -309,11 +321,13 @@ INT_PTR CALLBACK popup(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
309321
i++;
310322
}
311323
EnableWindow(GetDlgItem(hDlg, IDC_TEST), FALSE);
312-
capturing_WnE = -4;
324+
if (capturing_WnE == -5) capturing_WnE = -4;
325+
else if (capturing_WnE == -7) capturing_WnE = -6;
313326
}
314327
else
315328
{
316-
capturing_WnE = -4;
329+
if (capturing_WnE == 0) capturing_WnE = -4;
330+
if (capturing_WnE == -1) capturing_WnE = -6;
317331
KillTimer(hDlg, 1);
318332
KillTimer(hDlg, 2);
319333
KillTimer(hDlg, 3);
@@ -330,6 +344,7 @@ INT_PTR CALLBACK popup(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
330344
ShowWindow(GetDlgItem(hDlg, IDC_WINDOW), SW_HIDE);
331345
ShowWindow(GetDlgItem(hDlg, IDC_PEN), SW_HIDE);
332346
ShowWindow(GetDlgItem(hDlg, IDC_ERASER), SW_HIDE);
347+
SendMessage(GetDlgItem(hDlg, IDC_LIST1), LB_RESETCONTENT, 0, 0);
333348
for (auto it = config_data["pen_and_eraser_save"].begin(); it != config_data["pen_and_eraser_save"].end(); it++)
334349
{
335350
string key = it.key();
@@ -1857,7 +1872,8 @@ void* capture_Element()
18571872
capturing_WnE = -1;
18581873
SetDlgItemText(hwnd_popup, IDC_S6, L"当前控件组合不支持,请重新捕获");
18591874
EnableWindow(GetDlgItem(hwnd_popup, IDC_START), TRUE);
1860-
EnableWindow(GetDlgItem(hwnd_popup, IDC_TEST), FALSE);
1875+
EnableWindow(GetDlgItem(hwnd_popup, IDC_TEST), TRUE);
1876+
SetDlgItemText(hwnd_popup, IDC_TEST, L"已捕获列表");
18611877
SetDlgItemText(hwnd_popup, IDC_WINDOW, L"未获取");
18621878
SetDlgItemText(hwnd_popup, IDC_PEN, L"未获取");
18631879
SetDlgItemText(hwnd_popup, IDC_ERASER, L"未获取");
@@ -1888,7 +1904,8 @@ void* capture_Element()
18881904
capturing_WnE = -1;
18891905
SetDlgItemText(hwnd_popup, IDC_S6, L"无法定位控件,请重新捕获");
18901906
EnableWindow(GetDlgItem(hwnd_popup, IDC_START), TRUE);
1891-
EnableWindow(GetDlgItem(hwnd_popup, IDC_TEST), FALSE);
1907+
EnableWindow(GetDlgItem(hwnd_popup, IDC_TEST), TRUE);
1908+
SetDlgItemText(hwnd_popup, IDC_TEST, L"已捕获列表");
18921909
SetDlgItemText(hwnd_popup, IDC_WINDOW, L"未获取");
18931910
SetDlgItemText(hwnd_popup, IDC_PEN, L"未获取");
18941911
SetDlgItemText(hwnd_popup, IDC_ERASER, L"未获取");
@@ -1927,7 +1944,8 @@ void* capture_Element()
19271944
capturing_WnE = -1;
19281945
SetDlgItemText(hwnd_popup, IDC_S6, L"当前控件组合不支持,请重新捕获");
19291946
EnableWindow(GetDlgItem(hwnd_popup, IDC_START), TRUE);
1930-
EnableWindow(GetDlgItem(hwnd_popup, IDC_TEST), FALSE);
1947+
EnableWindow(GetDlgItem(hwnd_popup, IDC_TEST), TRUE);
1948+
SetDlgItemText(hwnd_popup, IDC_TEST, L"已捕获列表");
19311949
SetDlgItemText(hwnd_popup, IDC_WINDOW, L"未获取");
19321950
SetDlgItemText(hwnd_popup, IDC_PEN, L"未获取");
19331951
SetDlgItemText(hwnd_popup, IDC_ERASER, L"未获取");

0 commit comments

Comments
 (0)