From 19b2b5e0ec8bfdb105ebdafd17e5d1ea02831e10 Mon Sep 17 00:00:00 2001 From: henrypp Date: Sat, 6 Jul 2019 19:45:18 +0600 Subject: [PATCH] added notifications always on top option --- src/main.cpp | 19 ++++-- src/notifications.cpp | 2 +- src/resource.hpp | 131 +++++++++++++++++++++--------------------- src/resource.rc | 13 +++-- 4 files changed, 89 insertions(+), 76 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 59d95cea..5f44c0f2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1453,6 +1453,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam CheckDlgButton (hwnd, IDC_ENABLENOTIFICATIONS_CHK, app.ConfigGet (L"IsNotificationsEnabled", true).AsBool () ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton (hwnd, IDC_NOTIFICATIONSOUND_CHK, app.ConfigGet (L"IsNotificationsSound", true).AsBool () ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton (hwnd, IDC_NOTIFICATIONONTRAY_CHK, app.ConfigGet (L"IsNotificationsOnTray", false).AsBool () ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton (hwnd, IDC_NOTIFICATIONONTOP_CHK, app.ConfigGet (L"IsNotificationsOnTop", true).AsBool () ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage (hwnd, IDC_NOTIFICATIONTIMEOUT, UDM_SETRANGE32, 0, _R_SECONDSCLOCK_DAY (7)); SendDlgItemMessage (hwnd, IDC_NOTIFICATIONTIMEOUT, UDM_SETPOS32, 0, app.ConfigGet (L"NotificationsTimeout", NOTIFY_TIMEOUT_DEFAULT).AsUint ()); @@ -1608,6 +1609,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam SetDlgItemText (hwnd, IDC_ENABLENOTIFICATIONS_CHK, app.LocaleString (IDS_ENABLENOTIFICATIONS_CHK, nullptr)); SetDlgItemText (hwnd, IDC_NOTIFICATIONSOUND_CHK, app.LocaleString (IDS_NOTIFICATIONSOUND_CHK, nullptr)); SetDlgItemText (hwnd, IDC_NOTIFICATIONONTRAY_CHK, app.LocaleString (IDS_NOTIFICATIONONTRAY_CHK, nullptr)); + SetDlgItemText (hwnd, IDC_NOTIFICATIONONTOP_CHK, app.LocaleString (IDS_ALWAYSONTOP_CHK, nullptr)); SetDlgItemText (hwnd, IDC_NOTIFICATIONTIMEOUT_HINT, app.LocaleString (IDS_NOTIFICATIONTIMEOUT_HINT, nullptr)); @@ -1844,6 +1846,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam case IDC_ENABLENOTIFICATIONS_CHK: case IDC_NOTIFICATIONSOUND_CHK: case IDC_NOTIFICATIONONTRAY_CHK: + case IDC_NOTIFICATIONONTOP_CHK: case IDC_NOTIFICATIONTIMEOUT_CTRL: case IDC_EXCLUDESTEALTH_CHK: case IDC_EXCLUDECLASSIFYALLOW_CHK: @@ -1879,7 +1882,7 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam #if !defined(_APP_BETA) && !defined(_APP_BETA_RC) _r_ctrl_enable (hwnd, IDC_CHECKUPDATESBETA_CHK, (IsDlgButtonChecked (hwnd, ctrl_id) == BST_CHECKED) ? true : false); #endif - } + } else if (ctrl_id == IDC_CHECKUPDATESBETA_CHK) { app.ConfigSet (L"CheckUpdatesBeta", (IsDlgButtonChecked (hwnd, ctrl_id) == BST_CHECKED) ? true : false); @@ -2175,6 +2178,14 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam { app.ConfigSet (L"IsNotificationsOnTray", (IsDlgButtonChecked (hwnd, ctrl_id) == BST_CHECKED)); } + else if (ctrl_id == IDC_NOTIFICATIONONTOP_CHK) + { + const bool is_enabled = (IsDlgButtonChecked (hwnd, ctrl_id) == BST_CHECKED); + + _r_wnd_top (config.hnotification, is_enabled); + + app.ConfigSet (L"IsNotificationsOnTop", is_enabled); + } else if (ctrl_id == IDC_NOTIFICATIONTIMEOUT_CTRL && notify_code == EN_KILLFOCUS) { app.ConfigSet (L"NotificationsTimeout", (DWORD)SendDlgItemMessage (hwnd, IDC_NOTIFICATIONTIMEOUT, UDM_GETPOS32, 0, 0)); @@ -2197,12 +2208,12 @@ INT_PTR CALLBACK SettingsProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam } break; - } } + } break; - } } +} return FALSE; } @@ -2447,7 +2458,7 @@ void _app_toolbar_init (HWND hwnd) SendMessage (config.hrebar, RB_INSERTBAND, 0, (LPARAM)& rbi); BringWindowToTop (config.hrebar); // HACK!!! -} + } void _app_initialize () { diff --git a/src/notifications.cpp b/src/notifications.cpp index aa5cce39..2058fda2 100644 --- a/src/notifications.cpp +++ b/src/notifications.cpp @@ -48,7 +48,7 @@ void _app_notifycreatewindow () const INT title_font_height = 12; const INT text_font_height = 9; - config.hnotification = CreateWindowEx (WS_EX_APPWINDOW, NOTIFY_CLASS_DLG, nullptr, WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, app.GetDPI (NOTIFY_WIDTH), app.GetDPI (NOTIFY_HEIGHT), 0, nullptr, wcex.hInstance, nullptr); + config.hnotification = CreateWindowEx (WS_EX_APPWINDOW | (app.ConfigGet (L"IsNotificationsOnTop", true).AsBool () ? WS_EX_TOPMOST : 0), NOTIFY_CLASS_DLG, nullptr, WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, app.GetDPI (NOTIFY_WIDTH), app.GetDPI (NOTIFY_HEIGHT), 0, nullptr, wcex.hInstance, nullptr); if (!config.hnotification) return; diff --git a/src/resource.hpp b/src/resource.hpp index d9c5fc68..177e504a 100644 --- a/src/resource.hpp +++ b/src/resource.hpp @@ -147,83 +147,84 @@ #define IDC_ENABLENOTIFICATIONS_CHK 203 #define IDC_NOTIFICATIONSOUND_CHK 204 #define IDC_NOTIFICATIONONTRAY_CHK 205 -#define IDC_NOTIFICATIONTIMEOUT_HINT 206 -#define IDC_NOTIFICATIONTIMEOUT_CTRL 207 -#define IDC_NOTIFICATIONTIMEOUT 208 -#define IDC_EXCLUDESTEALTH_CHK 209 -#define IDC_EXCLUDECLASSIFYALLOW_CHK 210 -#define IDC_EXCLUDEBLOCKLIST_CHK 211 -#define IDC_EXCLUDECUSTOM_CHK 212 +#define IDC_NOTIFICATIONONTOP_CHK 206 +#define IDC_NOTIFICATIONTIMEOUT_HINT 207 +#define IDC_NOTIFICATIONTIMEOUT_CTRL 208 +#define IDC_NOTIFICATIONTIMEOUT 209 +#define IDC_EXCLUDESTEALTH_CHK 210 +#define IDC_EXCLUDECLASSIFYALLOW_CHK 211 +#define IDC_EXCLUDEBLOCKLIST_CHK 212 +#define IDC_EXCLUDECUSTOM_CHK 213 -#define IDC_ENABLELOG_CHK 213 -#define IDC_LOGPATH 214 -#define IDC_LOGPATH_BTN 215 +#define IDC_ENABLELOG_CHK 214 +#define IDC_LOGPATH 215 +#define IDC_LOGPATH_BTN 216 -#define IDC_LOGVIEWER_HINT 216 -#define IDC_LOGVIEWER 217 -#define IDC_LOGVIEWER_BTN 218 +#define IDC_LOGVIEWER_HINT 217 +#define IDC_LOGVIEWER 218 +#define IDC_LOGVIEWER_BTN 219 -#define IDC_LOGSIZELIMIT_HINT 219 -#define IDC_LOGSIZELIMIT_CTRL 220 -#define IDC_LOGSIZELIMIT 221 +#define IDC_LOGSIZELIMIT_HINT 220 +#define IDC_LOGSIZELIMIT_CTRL 221 +#define IDC_LOGSIZELIMIT 222 // Main Menu -#define IDM_SETTINGS 222 -#define IDM_EXIT 223 -#define IDM_PURGE_UNUSED 224 -#define IDM_PURGE_TIMERS 225 -#define IDM_FIND 226 -#define IDM_FINDNEXT 227 -#define IDM_REFRESH 228 -#define IDM_ALWAYSONTOP_CHK 229 -#define IDM_SHOWFILENAMESONLY_CHK 230 -#define IDM_AUTOSIZECOLUMNS_CHK 231 -#define IDM_ENABLESPECIALGROUP_CHK 232 -#define IDM_ICONSSMALL 233 -#define IDM_ICONSLARGE 234 -#define IDM_ICONSEXTRALARGE 235 -#define IDM_ICONSISTABLEVIEW 236 -#define IDM_ICONSISHIDDEN 237 -#define IDM_FONT 238 -#define IDM_WEBSITE 239 -#define IDM_CHECKUPDATES 240 -#define IDM_ABOUT 241 +#define IDM_SETTINGS 223 +#define IDM_EXIT 224 +#define IDM_PURGE_UNUSED 225 +#define IDM_PURGE_TIMERS 226 +#define IDM_FIND 227 +#define IDM_FINDNEXT 228 +#define IDM_REFRESH 229 +#define IDM_ALWAYSONTOP_CHK 230 +#define IDM_SHOWFILENAMESONLY_CHK 231 +#define IDM_AUTOSIZECOLUMNS_CHK 232 +#define IDM_ENABLESPECIALGROUP_CHK 233 +#define IDM_ICONSSMALL 234 +#define IDM_ICONSLARGE 235 +#define IDM_ICONSEXTRALARGE 236 +#define IDM_ICONSISTABLEVIEW 237 +#define IDM_ICONSISHIDDEN 238 +#define IDM_FONT 239 +#define IDM_WEBSITE 240 +#define IDM_CHECKUPDATES 241 +#define IDM_ABOUT 242 // Tray Menu -#define IDM_TRAY_SHOW 242 -#define IDM_TRAY_START 243 -#define IDM_TRAY_ENABLENOTIFICATIONS_CHK 244 -#define IDM_TRAY_ENABLENOTIFICATIONSSOUND_CHK 245 -#define IDM_TRAY_ENABLELOG_CHK 246 -#define IDM_TRAY_LOGSHOW 247 -#define IDM_TRAY_LOGCLEAR 248 -#define IDM_TRAY_LOGSHOW_ERR 249 -#define IDM_TRAY_LOGCLEAR_ERR 250 -#define IDM_TRAY_SETTINGS 251 -#define IDM_TRAY_WEBSITE 252 -#define IDM_TRAY_ABOUT 253 -#define IDM_TRAY_EXIT 254 +#define IDM_TRAY_SHOW 243 +#define IDM_TRAY_START 244 +#define IDM_TRAY_ENABLENOTIFICATIONS_CHK 245 +#define IDM_TRAY_ENABLENOTIFICATIONSSOUND_CHK 246 +#define IDM_TRAY_ENABLELOG_CHK 247 +#define IDM_TRAY_LOGSHOW 248 +#define IDM_TRAY_LOGCLEAR 249 +#define IDM_TRAY_LOGSHOW_ERR 250 +#define IDM_TRAY_LOGCLEAR_ERR 251 +#define IDM_TRAY_SETTINGS 252 +#define IDM_TRAY_WEBSITE 253 +#define IDM_TRAY_ABOUT 254 +#define IDM_TRAY_EXIT 255 // Listview Menu -#define IDM_ADD_FILE 255 -#define IDM_DISABLENOTIFICATIONS 256 -#define IDM_EDITRULES 257 -#define IDM_OPENRULESEDITOR 258 -#define IDM_EXPLORE 259 -#define IDM_COPY 260 -#define IDM_CHECK 261 -#define IDM_UNCHECK 262 -#define IDM_DELETE 263 -#define IDM_DISABLETIMER 264 -#define IDM_PROPERTIES 265 +#define IDM_ADD_FILE 256 +#define IDM_DISABLENOTIFICATIONS 257 +#define IDM_EDITRULES 258 +#define IDM_OPENRULESEDITOR 259 +#define IDM_EXPLORE 260 +#define IDM_COPY 261 +#define IDM_CHECK 262 +#define IDM_UNCHECK 263 +#define IDM_DELETE 264 +#define IDM_DISABLETIMER 265 +#define IDM_PROPERTIES 266 -#define IDM_IMPORT 266 -#define IDM_EXPORT 267 +#define IDM_IMPORT 267 +#define IDM_EXPORT 268 -#define IDM_NOTIMER 268 +#define IDM_NOTIMER 269 -#define IDM_SELECT_ALL 269 -#define IDM_ZOOM 270 +#define IDM_SELECT_ALL 270 +#define IDM_ZOOM 271 #define IDX_LANGUAGE 1000 #define IDX_TIMER 1200 diff --git a/src/resource.rc b/src/resource.rc index 80b6173a..65a181ce 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -344,20 +344,21 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU | WS_TABSTOP | WS_GROUP EXSTYLE WS_EX_CONTROLPARENT FONT 8, "Ms Shell Dlg" BEGIN - GROUPBOX "", IDC_TITLE_NOTIFICATIONS, 4, 4, 262, 70, WS_GROUP + GROUPBOX "", IDC_TITLE_NOTIFICATIONS, 4, 4, 262, 82, WS_GROUP AUTOCHECKBOX "", IDC_ENABLENOTIFICATIONS_CHK, 12, 16, 246, 10 AUTOCHECKBOX "", IDC_NOTIFICATIONSOUND_CHK, 12, 28, 246, 10 AUTOCHECKBOX "", IDC_NOTIFICATIONONTRAY_CHK, 12, 40, 246, 10 + AUTOCHECKBOX "", IDC_NOTIFICATIONONTOP_CHK, 12, 52, 246, 10 - LTEXT "", IDC_NOTIFICATIONTIMEOUT_HINT, 12, 54, 194, 12, SS_CENTERIMAGE - EDITTEXT IDC_NOTIFICATIONTIMEOUT_CTRL, 214, 54, 44, 12, ES_AUTOHSCROLL | ES_NUMBER | ES_MULTILINE + LTEXT "", IDC_NOTIFICATIONTIMEOUT_HINT, 12, 66, 194, 12, SS_CENTERIMAGE + EDITTEXT IDC_NOTIFICATIONTIMEOUT_CTRL, 214, 66, 44, 12, ES_AUTOHSCROLL | ES_NUMBER | ES_MULTILINE CONTROL "", IDC_NOTIFICATIONTIMEOUT, UPDOWN_CLASS, UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_AUTOBUDDY | UDS_HOTTRACK | UDS_SETBUDDYINT | UDS_WRAP, 0, 0, 0, 0 - GROUPBOX "", IDC_TITLE_EXCLUDE, 4, 76, 262, 42, WS_GROUP + GROUPBOX "", IDC_TITLE_EXCLUDE, 4, 88, 262, 42, WS_GROUP - AUTOCHECKBOX "", IDC_EXCLUDEBLOCKLIST_CHK, 12, 88, 246, 12 - AUTOCHECKBOX "", IDC_EXCLUDECUSTOM_CHK, 12, 100, 246, 12 + AUTOCHECKBOX "", IDC_EXCLUDEBLOCKLIST_CHK, 12, 100, 246, 12 + AUTOCHECKBOX "", IDC_EXCLUDECUSTOM_CHK, 12, 112, 246, 12 END IDD_SETTINGS_LOGGING DIALOGEX 107, 0, 272, 186