From 01727c04f0d4a702cb32b964dabef6d095c0ff68 Mon Sep 17 00:00:00 2001 From: Mina Brown Date: Mon, 11 Aug 2025 15:33:32 -0400 Subject: [PATCH] Remove the battery warning The battery warning could be annoying, and the option to disable it is confusing to somebody who may never see it. --- README.md | 1 - WinPowerDMS/WinPowerDMS.c | 14 +------------- WinPowerDMS/WinPowerDMS.rc | Bin 6678 -> 6356 bytes WinPowerDMS/resource.h | 3 +-- 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7a438ed..f823652 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ This is a simple C program written using Visual Studio 2022 that has no external - [x] Add a checkbox to preferences for starting at login. - [x] Add an icon. - [ ] Add behavior for when multiple displays are connected. -- [x] Warn the user when the system has no battery. - [x] Make the default display mode the current one instead of the highest resolution if there are no preferences set. - [ ] Make an actual about dialog. - [ ] Support dark mode. \ No newline at end of file diff --git a/WinPowerDMS/WinPowerDMS.c b/WinPowerDMS/WinPowerDMS.c index 52801f4..8bbb4aa 100644 --- a/WinPowerDMS/WinPowerDMS.c +++ b/WinPowerDMS/WinPowerDMS.c @@ -124,7 +124,6 @@ static void TestDisplayMode(HWND hDlg, DISPLAY_MODE* mode) { typedef struct { DISPLAY_MODE modeBatt; DISPLAY_MODE modeAC; - DWORD disableBatteryWarning; BOOL runAtStartup; } WINPOWERDMS_PREFS; @@ -145,7 +144,6 @@ static BOOL SavePrefs(void) { RegSetKeyValue(regKey, L"AC Power", L"Width", REG_DWORD, &userPrefs.modeAC.width, sizeof(userPrefs.modeAC.width)); RegSetKeyValue(regKey, L"AC Power", L"Height", REG_DWORD, &userPrefs.modeAC.height, sizeof(userPrefs.modeAC.height)); RegSetKeyValue(regKey, L"AC Power", L"Refresh Rate", REG_DWORD, &userPrefs.modeAC.refresh, sizeof(userPrefs.modeAC.refresh)); - RegSetValueEx(regKey, L"Disable Battery Warning", 0, REG_DWORD, &userPrefs.disableBatteryWarning, sizeof(userPrefs.disableBatteryWarning)); RegCloseKey(regKey); saved = TRUE; } @@ -180,8 +178,6 @@ static BOOL LoadPrefs(void) { RegGetValue(regKey, L"AC Power", L"Height", RRF_RT_REG_DWORD, NULL, &userPrefs.modeAC.height, &keySize); keySize = sizeof(userPrefs.modeAC.refresh); RegGetValue(regKey, L"AC Power", L"Refresh Rate", RRF_RT_REG_DWORD, NULL, &userPrefs.modeAC.refresh, &keySize); - keySize = sizeof(userPrefs.disableBatteryWarning); - RegGetValue(regKey, NULL, L"Disable Battery Warning", RRF_RT_REG_DWORD, NULL, &userPrefs.disableBatteryWarning, &keySize); RegCloseKey(regKey); loaded = TRUE; } @@ -206,8 +202,7 @@ static DISPLAY_MODE GetCurrentDisplayMode(void) { static INT_PTR CALLBACK PrefsDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND hComboBatt = GetDlgItem(hDlg, IDC_COMBO_BATT); HWND hComboAC = GetDlgItem(hDlg, IDC_COMBO_AC); - HWND hCheckBattWarning = GetDlgItem(hDlg, IDC_CHECK_BATT_WARNING); - HWND hCheckStartup = GetDlgItem(hCheckBattWarning, IDC_CHECK_STARTUP); + HWND hCheckStartup = GetDlgItem(hDlg, IDC_CHECK_STARTUP); switch (uMsg) { case WM_INITDIALOG: { @@ -246,7 +241,6 @@ static INT_PTR CALLBACK PrefsDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPA } } - SendMessage(hCheckBattWarning, BM_SETCHECK, userPrefs.disableBatteryWarning ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(hCheckStartup, BM_SETCHECK, userPrefs.runAtStartup ? BST_CHECKED : BST_UNCHECKED, 0); return TRUE; } @@ -257,7 +251,6 @@ static INT_PTR CALLBACK PrefsDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPA case IDOK: { userPrefs.modeBatt = GetModeFromCB(hComboBatt); userPrefs.modeAC = GetModeFromCB(hComboAC); - userPrefs.disableBatteryWarning = SendMessage(hCheckBattWarning, BM_GETCHECK, 0, 0) == BST_CHECKED; userPrefs.runAtStartup = SendMessage(hCheckStartup, BM_GETCHECK, 0, 0) == BST_CHECKED; SavePrefs(); if (LOWORD(wParam) == IDC_BUTTON_APPLY) return TRUE; @@ -359,11 +352,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine HWND hWnd = CreateWindowEx(0, L"TrayAppClass", NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, hInstance, NULL); RegisterPowerSettingNotification(hWnd, &GUID_ACDC_POWER_SOURCE, DEVICE_NOTIFY_WINDOW_HANDLE); - - // Check if there is a battery in the system and display a warning message if there isn't one. - SYSTEM_POWER_STATUS powerStatus; - if (!userPrefs.disableBatteryWarning && GetSystemPowerStatus(&powerStatus) && powerStatus.BatteryFlag == 128) - MessageBox(hWnd, L"There is no battery present in the system. The program will start and set your display mode to what you have set for AC power, but do nothing else afterwards.", L"WinPowerDMS", MB_OK | MB_ICONWARNING); // Create context menu hMenu = CreatePopupMenu(); diff --git a/WinPowerDMS/WinPowerDMS.rc b/WinPowerDMS/WinPowerDMS.rc index 49985048ba9bc2579b082843b87369e31813496c..802d22f91af6b44d7588bc5253a17f71c48c1e19 100644 GIT binary patch delta 83 zcmbPca>Z~%4F|IYgURN4j{S_xW(>xY9l4UBwB+OiT+0|OHm7rQGcg)ZF6QkAlFWR? aaOo@jI~WZ%_X=b)F`F}(Z~iSL%?<$39v0pJ delta 239 zcmca&IL%~34F|I&gW=|Sj{S_x<_rdt9l4UBwB+OiT+0~EH>Y!RGcg)XF6QkAlFWR? zaOp{WO2IA+nGD4Yi3~{$ISi=`3Jm2yb`e7!P&AJr9n8-Fisu1YNkEwrAWQ|yR|5GU zeR&M(KoJFo0-#tbkPlK>GWk58q^uKzBSQ!f#xsNiSwReb44y#j&Y;7<%fK}`P*i?$ yf+*MI2V5+Z|M2+;nlM-ZWege27!1I)!Q@uHql^}tz4^15m@ODgHt!UaW(NSsVKjdL diff --git a/WinPowerDMS/resource.h b/WinPowerDMS/resource.h index af56e51..4c137e1 100644 --- a/WinPowerDMS/resource.h +++ b/WinPowerDMS/resource.h @@ -10,8 +10,7 @@ #define IDC_BUTTON_TEST_AC 1004 #define IDC_BUTTON_APPLY 1005 #define IDC_LIST1 1006 -#define IDC_CHECK_BATT_WARNING 1007 -#define IDC_CHECK_STARTUP 1008 +#define IDC_CHECK_STARTUP 1007 // Next default values for new objects //