From 8035df552615faa82c399949cae49d5326a47406 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 28 Feb 2016 17:01:35 +0000 Subject: [PATCH] [INPUT] Prevent removal of all languages from the language list by disabling the 'Remove' button when only one item remains. Enable the 'Remove' button when there is more than one item in the list. CORE-3587 #resolve svn path=/trunk/; revision=70799 --- reactos/dll/cpl/input/settings.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/reactos/dll/cpl/input/settings.c b/reactos/dll/cpl/input/settings.c index b308c9a7a5b..37275ee1842 100644 --- a/reactos/dll/cpl/input/settings.c +++ b/reactos/dll/cpl/input/settings.c @@ -743,8 +743,13 @@ SettingsPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) hImgList = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 0, 1); InitLangList(hwndDlg, hImgList); (VOID) ListView_SetImageList(GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST), hImgList, LVSIL_SMALL); + + /* Disable the Remove button if there is only one layout in the layout list */ + if (ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST)) <= 1) + EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE_BUTTON), FALSE); } break; + case WM_NOTIFY: { switch (LOWORD(wParam)) @@ -753,11 +758,16 @@ SettingsPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) } } break; + case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_REMOVE_BUTTON: DeleteLayout(); + + /* Disable the Remove button if there is only one layout in the layout list */ + if (ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST)) <= 1) + EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE_BUTTON), FALSE); break; case IDC_KEY_SET_BTN: @@ -772,6 +782,10 @@ SettingsPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) MAKEINTRESOURCE(IDD_ADD), hwndDlg, AddDlgProc); + + /* Enable the Remove button if there is more than one layout in the layout list */ + if (ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST)) > 1) + EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE_BUTTON), TRUE); break; case IDC_PROP_BUTTON: @@ -788,6 +802,7 @@ SettingsPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) break; } break; + case WM_DESTROY: break; }