From 6712ce9307350ef5c04f184b0cb80cfe75af77c5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 7 Mar 2019 22:38:02 +0300 Subject: Srmm_ModifyIcon now changes only tooltip and/or icon, Srmm_SetIconFlags controls flags --- .../src/historysweeperlight.cpp | 10 +-- plugins/HistorySweeperLight/src/main.cpp | 32 +++------ plugins/HistorySweeperLight/src/options.cpp | 78 ++++++++++------------ plugins/HistorySweeperLight/src/stdafx.h | 4 +- 4 files changed, 49 insertions(+), 75 deletions(-) (limited to 'plugins/HistorySweeperLight') diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp index 57a7e649b6..91c3478011 100644 --- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp +++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp @@ -239,12 +239,6 @@ void SetSrmmIcon(MCONTACT hContact) { int sweep = g_plugin.getByte(hContact, "SweepHistory"); - StatusIconData sid = {}; - sid.szModule = MODULENAME; - - for (int i = 0; i < 4; i++) { - sid.dwId = i; - sid.flags = (sweep == i) ? 0 : MBF_HIDDEN; - Srmm_ModifyIcon(hContact, &sid); - } + for (int i = 0; i < 4; i++) + Srmm_SetIconFlags(hContact, MODULENAME, i, (sweep == i) ? 0 : MBF_HIDDEN); } diff --git a/plugins/HistorySweeperLight/src/main.cpp b/plugins/HistorySweeperLight/src/main.cpp index b33612d569..7d4ecd5311 100644 --- a/plugins/HistorySweeperLight/src/main.cpp +++ b/plugins/HistorySweeperLight/src/main.cpp @@ -53,19 +53,12 @@ static int OnIconPressed(WPARAM hContact, LPARAM lParam) if (!(sicd->flags & MBCF_RIGHTBUTTON) && !mir_strcmp(sicd->szModule, MODULENAME) && g_plugin.getByte("ChangeInMW", 0)) { int nh = sicd->dwId; - - StatusIconData sid = {}; - sid.szModule = MODULENAME; - sid.dwId = nh; - sid.flags = MBF_HIDDEN; - Srmm_ModifyIcon(hContact, &sid); + Srmm_SetIconFlags(hContact, MODULENAME, nh, MBF_HIDDEN); nh = (nh + 1) % 4; - g_plugin.setByte(hContact, "SweepHistory", (BYTE)nh); - sid.dwId = nh; - sid.flags = 0; - Srmm_ModifyIcon(hContact, &sid); + g_plugin.setByte(hContact, "SweepHistory", (BYTE)nh); + Srmm_SetIconFlags(hContact, MODULENAME, nh, 0); } return 0; } @@ -79,33 +72,30 @@ static int OnModulesLoaded(WPARAM, LPARAM) sid.hIcon = LoadIconEx("actG"); if (sweep == 0) - sid.szTooltip.a = LPGEN("Keep all events"); + sid.szTooltip.w = LPGENW("Keep all events"); else if (sweep == 1) - sid.szTooltip.a = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]; + sid.szTooltip.w = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]; else if (sweep == 2) - sid.szTooltip.a = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]; + sid.szTooltip.w = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]; else if (sweep == 3) - sid.szTooltip.a = LPGEN("Delete all events"); + sid.szTooltip.w = LPGENW("Delete all events"); - sid.flags = MBF_HIDDEN; + sid.flags = MBF_HIDDEN | MBF_UNICODE; Srmm_AddIcon(&sid, &g_plugin); sid.dwId = 1; sid.hIcon = LoadIconEx("act1"); - sid.szTooltip.a = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]; - sid.flags = MBF_HIDDEN; + sid.szTooltip.w = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]; Srmm_AddIcon(&sid, &g_plugin); sid.dwId = 2; sid.hIcon = LoadIconEx("act2"); - sid.szTooltip.a = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]; - sid.flags = MBF_HIDDEN; + sid.szTooltip.w = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]; Srmm_AddIcon(&sid, &g_plugin); sid.dwId = 3; sid.hIcon = LoadIconEx("actDel"); - sid.szTooltip.a = LPGEN("Delete all events"); - sid.flags = MBF_HIDDEN; + sid.szTooltip.w = LPGENW("Delete all events"); Srmm_AddIcon(&sid, &g_plugin); HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent); diff --git a/plugins/HistorySweeperLight/src/options.cpp b/plugins/HistorySweeperLight/src/options.cpp index 314cfb43d1..4dc71814f8 100644 --- a/plugins/HistorySweeperLight/src/options.cpp +++ b/plugins/HistorySweeperLight/src/options.cpp @@ -22,26 +22,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" // Time Stamps strings -char* time_stamp_strings[] = +wchar_t* time_stamp_strings[] = { - LPGEN("Delete older than 1 day"), - LPGEN("Delete older than 3 days"), - LPGEN("Delete older than 7 days"), - LPGEN("Delete older than 2 weeks (14 days)"), - LPGEN("Delete older than 1 month (30 days)"), - LPGEN("Delete older than 3 months (90 days)"), - LPGEN("Delete older than 6 months (180 days)"), - LPGEN("Delete older than 1 year (365 days)") + LPGENW("Delete older than 1 day"), + LPGENW("Delete older than 3 days"), + LPGENW("Delete older than 7 days"), + LPGENW("Delete older than 2 weeks (14 days)"), + LPGENW("Delete older than 1 month (30 days)"), + LPGENW("Delete older than 3 months (90 days)"), + LPGENW("Delete older than 6 months (180 days)"), + LPGENW("Delete older than 1 year (365 days)") }; -char* keep_strings[] = +wchar_t* keep_strings[] = { - LPGEN("Keep 1 last event"), - LPGEN("Keep 2 last events"), - LPGEN("Keep 5 last events"), - LPGEN("Keep 10 last events"), - LPGEN("Keep 20 last events"), - LPGEN("Keep 50 last events") + LPGENW("Keep 1 last event"), + LPGENW("Keep 2 last events"), + LPGENW("Keep 5 last events"), + LPGENW("Keep 10 last events"), + LPGENW("Keep 20 last events"), + LPGENW("Keep 50 last events") }; static IconItem iconList[] = @@ -75,7 +75,7 @@ HANDLE GetIconHandle(const char* name) return nullptr; } -void ReleaseIconEx(const char* name) +void ReleaseIconEx(const char* name) { char szSettingName[100]; mir_snprintf(szSettingName, "%s_%s", MODULENAME, name); @@ -117,15 +117,11 @@ void LoadSettings(HWND hwndDlg) SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_RESETCONTENT, 0, 0); - for (auto &it : time_stamp_strings) { - ptrW ptszTimeStr(Langpack_PcharToTchar(it)); - SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr); - } + for (auto &it : time_stamp_strings) + SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_ADDSTRING, 0, (LPARAM)TranslateW(it)); - for (auto &it : keep_strings) { - ptrW ptszTimeStr(Langpack_PcharToTchar(it)); - SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr); - } + for (auto &it : keep_strings) + SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_ADDSTRING, 0, (LPARAM)TranslateW(it)); SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_SETCURSEL, g_plugin.getByte("StartupShutdownOlder", 0), 0); SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_SETCURSEL, g_plugin.getByte("StartupShutdownKeep", 0), 0); @@ -164,25 +160,19 @@ void SaveSettings(HWND hwndDlg) // set tooltips int st = g_plugin.getByte("SweepHistory", 0); - StatusIconData sid = {}; - sid.szModule = MODULENAME; - sid.dwId = 0; - sid.hIcon = LoadIconEx("actG"); - if (st == 0) sid.szTooltip.a = LPGEN("Keep all events"); - else if (st == 1) sid.szTooltip.a = LPGEN(time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]); - else if (st == 2) sid.szTooltip.a = LPGEN(keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]); - else if (st == 3) sid.szTooltip.a = LPGEN("Delete all events"); - Srmm_ModifyIcon(NULL, &sid); - - sid.dwId = 1; - sid.hIcon = LoadIconEx("act1"); - sid.szTooltip.a = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]; - Srmm_ModifyIcon(NULL, &sid); - - sid.dwId = 2; - sid.hIcon = LoadIconEx("act2"); - sid.szTooltip.a = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]; - Srmm_ModifyIcon(NULL, &sid); + const wchar_t *pwszToolTip = nullptr; + if (st == 0) + pwszToolTip = LPGENW("Keep all events"); + else if (st == 1) + pwszToolTip = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]; + else if (st == 2) + pwszToolTip = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]; + else if (st == 3) + pwszToolTip = LPGENW("Delete all events"); + Srmm_ModifyIcon(NULL, MODULENAME, 0, nullptr, pwszToolTip); + + Srmm_ModifyIcon(NULL, MODULENAME, 1, nullptr, time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]); + Srmm_ModifyIcon(NULL, MODULENAME, 2, nullptr, keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]); } INT_PTR CALLBACK DlgProcHSOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) diff --git a/plugins/HistorySweeperLight/src/stdafx.h b/plugins/HistorySweeperLight/src/stdafx.h index 5172588f6b..5d68a9c2bb 100644 --- a/plugins/HistorySweeperLight/src/stdafx.h +++ b/plugins/HistorySweeperLight/src/stdafx.h @@ -56,8 +56,8 @@ struct CMPlugin : public PLUGIN extern LIST g_hWindows; // options.c -extern char* time_stamp_strings[]; -extern char* keep_strings[]; +extern wchar_t* time_stamp_strings[]; +extern wchar_t* keep_strings[]; int HSOptInitialise(WPARAM wParam, LPARAM lParam); void InitIcons(void); void ReleaseIconEx(const char* name); -- cgit v1.2.3