summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-06-10 19:13:40 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-06-10 19:13:40 +0300
commit4ddea205205f8172cef709752fa723db743b4316 (patch)
tree6324018969a9aa3892bc659eb94627d861318f6a
parentc677ad260e08dd06946cb48e928509cef4701504 (diff)
fixes #2886 (большие иконки для погоды во вспомогательных окнах)
-rw-r--r--protocols/Weather/src/stdafx.h1
-rw-r--r--protocols/Weather/src/weather.cpp4
-rw-r--r--protocols/Weather/src/weather_svcs.cpp14
-rw-r--r--protocols/Weather/src/weather_userinfo.cpp15
4 files changed, 28 insertions, 6 deletions
diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h
index a734e91a14..10b851e826 100644
--- a/protocols/Weather/src/stdafx.h
+++ b/protocols/Weather/src/stdafx.h
@@ -394,6 +394,7 @@ void GetElev(wchar_t *tempchar, wchar_t *unit, wchar_t *str);
void ClearStatusIcons();
int MapCondToStatus(MCONTACT hContact);
HICON GetStatusIcon(MCONTACT hContact);
+HICON GetStatusIconBig(MCONTACT hContact);
WORD GetIcon(const wchar_t* cond, WIDATA *Data);
void CaseConv(wchar_t *str);
diff --git a/protocols/Weather/src/weather.cpp b/protocols/Weather/src/weather.cpp
index bb2a7cbbd0..259426957b 100644
--- a/protocols/Weather/src/weather.cpp
+++ b/protocols/Weather/src/weather.cpp
@@ -55,6 +55,8 @@ BOOL ThreadRunning;
// variable to determine if module loaded
BOOL ModuleLoaded = FALSE;
+VARSW g_pwszIconsName(L"%miranda_path%\\Icons\\proto_Weather.dll");
+
HANDLE hTBButton = nullptr;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -159,7 +161,7 @@ int CMPlugin::Load()
g_plugin.registerIcon(MODULENAME, iconList, MODULENAME);
// load dll with icons
- hIconsDll = LoadLibraryW(VARSW(L"%miranda_path%\\Icons\\proto_Weather.dll"));
+ hIconsDll = LoadLibraryW(g_pwszIconsName);
// load options and set defaults
LoadOptions();
diff --git a/protocols/Weather/src/weather_svcs.cpp b/protocols/Weather/src/weather_svcs.cpp
index 7fa2b40000..2d143d5172 100644
--- a/protocols/Weather/src/weather_svcs.cpp
+++ b/protocols/Weather/src/weather_svcs.cpp
@@ -29,6 +29,8 @@ building/changing the weather menu items.
static HGENMENU hEnableDisablePopupMenu;
static HGENMENU hEnableDisableMenu;
+extern VARSW g_pwszIconsName;
+
//============ MIRANDA PROTOCOL SERVICES ============
// protocol service function for setting weather protocol status
@@ -230,6 +232,18 @@ HICON GetStatusIcon(MCONTACT hContact)
return ImageList_GetIcon(Clist_GetImageList(), pIcon.clistIconId, ILD_NORMAL);
}
+HICON GetStatusIconBig(MCONTACT hContact)
+{
+ int iCond = g_plugin.getWord(hContact, "StatusIcon", -1);
+ if (iCond < 0 || iCond >= MAX_COND)
+ return nullptr;
+
+ HICON hIcon;
+ auto &pIcon = statusIcons[iCond];
+ ExtractIconExW(g_pwszIconsName, -pIcon.iconIdx, &hIcon, 0, 1);
+ return hIcon;
+}
+
static INT_PTR WeatherAdvancedStatusIcon(WPARAM hContact, LPARAM)
{
if (!hContact || !g_plugin.hIconsDll)
diff --git a/protocols/Weather/src/weather_userinfo.cpp b/protocols/Weather/src/weather_userinfo.cpp
index 0f69dfa42c..e0420d48bf 100644
--- a/protocols/Weather/src/weather_userinfo.cpp
+++ b/protocols/Weather/src/weather_userinfo.cpp
@@ -130,8 +130,11 @@ static INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, L
DBDataManage(hContact, WDBM_DETAILDISPLAY, (WPARAM)hwndDlg, 0);
// set icons
- Window_FreeIcon_IcoLib(hwndDlg);
- Window_SetProtoIcon_IcoLib(hwndDlg, MODULENAME, MapCondToStatus(hContact));
+ {
+ HICON hIcon = GetStatusIconBig(hContact);
+ DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, LPARAM(hIcon)));
+ DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, LPARAM(hIcon)));
+ }
RedrawWindow(GetDlgItem(hwndDlg, IDC_HEADERBAR), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
break;
@@ -225,7 +228,9 @@ static INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, L
break;
case WM_DESTROY:
- Window_FreeIcon_IcoLib(hwndDlg);
+ DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0));
+ DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0));
+
Utils_SaveWindowPosition(hwndDlg, NULL, MODULENAME, "BriefInfo_");
WindowList_Remove(hDataWindowList, hwndDlg);
break;
@@ -253,7 +258,7 @@ static INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
w = LoadWeatherInfo(lParam);
SetDlgItemText(hwndDlg, IDC_INFO1, GetDisplay(&w, TranslateT("Current condition for %n"), str));
- SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON, (WPARAM)Skin_LoadProtoIcon(MODULENAME, MapCondToStatus(hContact)), 0);
+ SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON, (WPARAM)GetStatusIconBig(hContact), 0);
{
// bold and enlarge the current condition
LOGFONT lf;
@@ -283,7 +288,7 @@ static INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
break;
case WM_DESTROY:
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON, 0, 0));
+ DestroyIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON, 0, 0));
DeleteObject((HFONT)SendDlgItemMessage(hwndDlg, IDC_INFO2, WM_GETFONT, 0, 0));
break;