https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1dcf8376f003ec8b6378a…
commit 1dcf8376f003ec8b6378ad22be6b6f58d7697a15
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun May 5 22:48:53 2019 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun May 5 22:48:53 2019 +0200
[POWERCFG] Fix power scheme deletion
CORE-12566, CORE-12567
---
dll/cpl/powercfg/powershemes.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/dll/cpl/powercfg/powershemes.c b/dll/cpl/powercfg/powershemes.c
index d68af58f3d..c237a21368 100644
--- a/dll/cpl/powercfg/powershemes.c
+++ b/dll/cpl/powercfg/powershemes.c
@@ -591,8 +591,11 @@ Pos_SaveData(
}
-static BOOL
-DelScheme(HWND hwnd)
+static
+BOOL
+DelScheme(
+ HWND hwnd,
+ PPOWER_SCHEMES_PAGE_DATA pPageData)
{
WCHAR szTitleBuffer[256];
WCHAR szRawBuffer[256], szCookedBuffer[512];
@@ -618,16 +621,24 @@ DelScheme(HWND hwnd)
if (MessageBoxW(hwnd, szCookedBuffer, szTitleBuffer, MB_YESNO | MB_ICONQUESTION |
MB_DEFBUTTON2) == IDYES)
{
- UINT Current;
-
- if (GetActivePwrScheme(&Current))
+ if (!DeletePwrScheme(pScheme->uId))
{
- SendMessage(hList, CB_SETCURSEL, (WPARAM)0, 0);
- SendMessage(hList, CB_DELETESTRING, (WPARAM)iCurSel, 0);
+ // FIXME: Show an error message box
+ return FALSE;
}
- if (DeletePwrScheme(pScheme->uId) != 0)
- return TRUE;
+ iCurSel = SendMessage(hList, CB_FINDSTRING, -1, (LPARAM)pScheme->pszName);
+ if (iCurSel != CB_ERR)
+ SendMessage(hList, CB_DELETESTRING, iCurSel, 0);
+
+ DeletePowerScheme(pScheme);
+
+ iCurSel = SendMessage(hList, CB_FINDSTRING, -1,
(LPARAM)pPageData->pActivePowerScheme->pszName);
+ if (iCurSel != CB_ERR)
+ SendMessage(hList, CB_SETCURSEL, iCurSel, 0);
+
+ LoadConfig(hwnd, pPageData);
+ return TRUE;
}
return FALSE;
@@ -780,7 +791,7 @@ PowerSchemesDlgProc(
break;
case IDC_DELETE_BTN:
- DelScheme(hwndDlg);
+ DelScheme(hwndDlg, pPageData);
break;
case IDC_SAVEAS_BTN: