diff --git a/src/helper.cpp b/src/helper.cpp index b57067d4..555c6152 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -43,33 +43,14 @@ void _app_dereferencestring (PVOID pdata) delete[] LPWSTR (pdata); } -INT _app_gettab_id (HWND hwnd, INT page_id) -{ - TCITEM tci = {0}; - - tci.mask = TCIF_PARAM; - - if (page_id == INVALID_INT) - { - page_id = (INT)SendDlgItemMessage (hwnd, IDC_TAB, TCM_GETCURSEL, 0, 0); - - if (page_id == INVALID_INT) - page_id = 0; - } - - SendDlgItemMessage (hwnd, IDC_TAB, TCM_GETITEM, (WPARAM)page_id, (LPARAM)&tci); - - return (INT)tci.lParam; -} - void _app_settab_id (HWND hwnd, INT page_id) { - if (!page_id || (_app_gettab_id (hwnd) == page_id && IsWindowVisible (GetDlgItem (hwnd, page_id)))) + if (!page_id || ((INT)_r_tab_getlparam (hwnd, IDC_TAB, INVALID_INT) == page_id && IsWindowVisible (GetDlgItem (hwnd, page_id)))) return; for (INT i = 0; i < (INT)SendDlgItemMessage (hwnd, IDC_TAB, TCM_GETITEMCOUNT, 0, 0); i++) { - const INT listview_id = _app_gettab_id (hwnd, i); + const INT listview_id = (INT)_r_tab_getlparam (hwnd, IDC_TAB, i); if (listview_id == page_id) { @@ -2335,7 +2316,7 @@ INT CALLBACK _app_listviewcompare_callback (LPARAM lparam1, LPARAM lparam2, LPAR result = _r_str_compare_logical ( _r_listview_getitemtext (hparent, listview_id, item1, column_id), _r_listview_getitemtext (hparent, listview_id, item2, column_id) - ); + ); } return is_descend ? -result : result; @@ -2442,7 +2423,7 @@ void _app_refreshstatus (HWND hwnd, INT listview_id) if (listview_id) { if (listview_id == INVALID_INT) - listview_id = _app_gettab_id (hwnd); + listview_id = (INT)_r_tab_getlparam (hwnd, IDC_TAB, INVALID_INT); if ((SendDlgItemMessage (hwnd, listview_id, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) & LVS_EX_CHECKBOXES) != 0) { diff --git a/src/helper.hpp b/src/helper.hpp index ef225eb4..d3217c93 100644 --- a/src/helper.hpp +++ b/src/helper.hpp @@ -17,7 +17,6 @@ void _app_dereferencerule (PVOID pdata); void _app_dereferenceruleconfig (PVOID pdata); void _app_dereferencestring (PVOID pdata); -INT _app_gettab_id (HWND hwnd, INT page_id = INVALID_INT); void _app_settab_id (HWND hwnd, INT page_id); bool _app_initinterfacestate (HWND hwnd, bool is_forced); diff --git a/src/log.cpp b/src/log.cpp index 4fed9058..c8b1f606 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -810,7 +810,7 @@ UINT WINAPI LogThread (LPVOID lparam) INT app_listview_id = 0; - if (_app_getappinfo (app_hash, InfoListviewId, &app_listview_id, sizeof (app_listview_id)) && app_listview_id == _app_gettab_id (hwnd)) + if (_app_getappinfo (app_hash, InfoListviewId, &app_listview_id, sizeof (app_listview_id)) && app_listview_id == (INT)_r_tab_getlparam (hwnd, IDC_TAB, INVALID_INT)) { _app_listviewsort (hwnd, app_listview_id); _app_refreshstatus (hwnd, app_listview_id); diff --git a/src/notifications.cpp b/src/notifications.cpp index 1720b86c..e4b4902d 100644 --- a/src/notifications.cpp +++ b/src/notifications.cpp @@ -73,7 +73,7 @@ bool _app_notifycommand (HWND hwnd, INT button_id, time_t seconds) _app_refreshstatus (app.GetHWND (), listview_id); _app_profile_save (); - if (listview_id && _app_gettab_id (app.GetHWND ()) == listview_id) + if (listview_id && _r_tab_getlparam (app.GetHWND (), IDC_TAB, INVALID_INT) == listview_id) { _app_listviewsort (app.GetHWND (), listview_id); _r_listview_redraw (app.GetHWND (), listview_id); @@ -763,6 +763,9 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp const HMENU hsubmenu = CreatePopupMenu (); + if (!hsubmenu) + break; + if (nmlp->idFrom == IDC_RULES_BTN) { AppendMenu (hsubmenu, MF_STRING, IDM_DISABLENOTIFICATIONS, app.LocaleString (IDS_DISABLENOTIFICATIONS, nullptr)); @@ -905,7 +908,7 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp _app_ruleenable (ptr_rule, true); } - const INT listview_id = _app_gettab_id (app.GetHWND ()); + const INT listview_id = (INT)_r_tab_getlparam (app.GetHWND (), IDC_TAB, INVALID_INT); const INT app_listview_id = _app_getlistview_id (ptr_app->type); const INT rule_listview_id = _app_getlistview_id (ptr_rule->type); @@ -1125,7 +1128,7 @@ INT_PTR CALLBACK NotificationProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp _r_fastlock_releaseshared (&lock_access); - const INT listview_id = _app_gettab_id (app.GetHWND ()); + const INT listview_id = (INT)_r_tab_getlparam (app.GetHWND (), IDC_TAB, INVALID_INT); // set rule information { diff --git a/src/profile.cpp b/src/profile.cpp index 81a07701..b970156c 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -423,7 +423,7 @@ rstring _app_gettooltip (INT listview_id, size_t lparam) { rstring result; - if ((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP) || listview_id == IDC_APPS_LV || listview_id == IDC_NETWORK) + if ((listview_id >= IDC_APPS_PROFILE && listview_id <= IDC_APPS_UWP) || listview_id == IDC_RULE_APPS || listview_id == IDC_NETWORK) { if (listview_id == IDC_NETWORK) { @@ -828,7 +828,7 @@ void _app_ruleblocklistset (HWND hwnd, INT spy_state, INT update_state, INT extr { if (hwnd) { - if (_app_gettab_id (hwnd) == listview_id) + if ((INT)_r_tab_getlparam (hwnd, IDC_TAB, INVALID_INT) == listview_id) _app_listviewsort (hwnd, listview_id); _app_refreshstatus (hwnd, listview_id); @@ -1387,7 +1387,7 @@ void _app_profile_load_internal (LPCWSTR path, LPCWSTR path_backup, time_t* ptim void _app_profile_load (HWND hwnd, LPCWSTR path_custom) { - const INT current_listview_id = _app_gettab_id (hwnd); + const INT current_listview_id = (INT)_r_tab_getlparam (hwnd, IDC_TAB, INVALID_INT); const INT selected_item = (INT)SendDlgItemMessage (hwnd, current_listview_id, LVM_GETNEXTITEM, (WPARAM)INVALID_INT, LVNI_SELECTED); const INT scroll_pos = GetScrollPos (GetDlgItem (hwnd, current_listview_id), SB_VERT); @@ -1661,12 +1661,15 @@ void _app_profile_load (HWND hwnd, LPCWSTR path_custom) if (hwnd && current_listview_id) { - const INT new_listview_id = _app_gettab_id (hwnd); + const INT new_listview_id = (INT)_r_tab_getlparam (hwnd, IDC_TAB, INVALID_INT); - _app_listviewsort (hwnd, new_listview_id); + if (new_listview_id) + { + _app_listviewsort (hwnd, new_listview_id); - if (current_listview_id == new_listview_id) - _app_showitem (hwnd, current_listview_id, selected_item, scroll_pos); + if (current_listview_id == new_listview_id) + _app_showitem (hwnd, current_listview_id, selected_item, scroll_pos); + } } } diff --git a/src/timer.cpp b/src/timer.cpp index 50b078d0..d4c3ec0b 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -165,7 +165,7 @@ void CALLBACK _app_timer_callback (PVOID lparam, BOOLEAN) _r_obj_dereference (ptr_app_object); - const INT listview_id = _app_gettab_id (hwnd); + const INT listview_id = (INT)_r_tab_getlparam (hwnd, IDC_TAB, INVALID_INT); _app_listviewsort (hwnd, listview_id); _app_refreshstatus (hwnd, listview_id);