summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-11-25 14:40:02 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-11-25 14:40:02 +0000
commit65a5f40baaae20a733da94df023221159b334e2b (patch)
tree5771f98d03384669e288f58dc10db4aa1b1a80fc
parent81464df93124380cecbf7e5dace914f1c06aaf5d (diff)
WhenWasIt - correct work with icons & extra icons
git-svn-id: http://svn.miranda-ng.org/main/trunk@2484 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/WhenWasIt/src/WhenWasIt.cpp2
-rw-r--r--plugins/WhenWasIt/src/birthdays.cpp97
-rw-r--r--plugins/WhenWasIt/src/commonheaders.h50
-rw-r--r--plugins/WhenWasIt/src/dlg_handlers.cpp141
-rw-r--r--plugins/WhenWasIt/src/hooked_events.cpp111
-rw-r--r--plugins/WhenWasIt/src/hooked_events.h2
-rw-r--r--plugins/WhenWasIt/src/icons.cpp153
-rw-r--r--plugins/WhenWasIt/src/icons.h29
-rw-r--r--plugins/WhenWasIt/src/notifiers.cpp36
-rw-r--r--plugins/WhenWasIt/src/notifiers.h21
-rw-r--r--plugins/WhenWasIt/src/resource.h20
-rw-r--r--plugins/WhenWasIt/src/services.cpp28
12 files changed, 221 insertions, 469 deletions
diff --git a/plugins/WhenWasIt/src/WhenWasIt.cpp b/plugins/WhenWasIt/src/WhenWasIt.cpp
index c99b540a22..07d7ce0548 100644
--- a/plugins/WhenWasIt/src/WhenWasIt.cpp
+++ b/plugins/WhenWasIt/src/WhenWasIt.cpp
@@ -63,7 +63,7 @@ extern "C" int __declspec(dllexport) Load(void)
icex.dwICC = ICC_DATE_CLASSES;
InitCommonControlsEx(&icex);
- LoadIcons();
+ AddIcons();
Log("%s", "Creating service functions ...");
InitServices();
diff --git a/plugins/WhenWasIt/src/birthdays.cpp b/plugins/WhenWasIt/src/birthdays.cpp
index d69207b444..4d4242e265 100644
--- a/plugins/WhenWasIt/src/birthdays.cpp
+++ b/plugins/WhenWasIt/src/birthdays.cpp
@@ -25,8 +25,8 @@ CBirthdays &birthdays = CBirthdays();
CBirthdays::CBirthdays(int initialSize)
{
- int count = 0;
- int size = 0;
+ count = 0;
+ size = 0;
birthdays = NULL;
advancedIcon = CLIST_ICON;
@@ -40,21 +40,18 @@ CBirthdays::~CBirthdays()
void CBirthdays::Destroy()
{
- if (birthdays)
- {
- Clear();
- free(birthdays);
- birthdays = NULL;
- }
+ if (birthdays) {
+ Clear();
+ free(birthdays);
+ birthdays = NULL;
+ }
}
void CBirthdays::Clear()
{
- int i;
- for (i = 0; i < Count(); i++)
- {
- ClearItem(i);
- }
+ for (int i = 0; i < Count(); i++)
+ ClearItem(i);
+
count = 0;
}
@@ -77,9 +74,7 @@ int CBirthdays::Size() const
void CBirthdays::EnsureCapacity()
{
if (count >= size)
- {
- Realloc(size / 2);
- }
+ Realloc(size / 2);
}
void CBirthdays::Realloc(int increaseCapacity)
@@ -90,62 +85,49 @@ void CBirthdays::Realloc(int increaseCapacity)
int CBirthdays::Add(HANDLE hContact, HANDLE hClistIcon)
{
- if ( !Contains(hContact))
- {
- EnsureCapacity();
- TBirthdayContact *item = (TBirthdayContact *) malloc(sizeof(TBirthdayContact));
- item->hContact = hContact;
- item->hClistIcon = hClistIcon;
- birthdays[count++] = item;
- return 0;
- }
+ if ( !Contains(hContact)) {
+ EnsureCapacity();
+ TBirthdayContact *item = (TBirthdayContact *) malloc(sizeof(TBirthdayContact));
+ item->hContact = hContact;
+ item->hClistIcon = hClistIcon;
+ birthdays[count++] = item;
+ return 0;
+ }
return -1;
}
int CBirthdays::Remove(int index)
{
- if ((index >= 0) && (index < count))
- {
- int i;
- for (i = index + 1; i < count; i++)
- {
- birthdays[i - 1] = birthdays[i];
- }
- ClearItem(count--);
- return 0;
- }
+ if ((index >= 0) && (index < count)) {
+ for (int i = index + 1; i < count; i++)
+ birthdays[i - 1] = birthdays[i];
+
+ ClearItem(count--);
+ return 0;
+ }
return -1;
}
int CBirthdays::Remove(HANDLE hContact)
{
- int index = Index(hContact);
- return Remove(index);
+ return Remove( Index(hContact));
}
int CBirthdays::Contains(HANDLE hContact) const
{
- int i;
- for (i = 0; i < count; i++)
- {
- if (birthdays[i]->hContact == hContact)
- {
- return TRUE;
- }
- }
+ for (int i = 0; i < count; i++)
+ if (birthdays[i]->hContact == hContact)
+ return TRUE;
+
return FALSE;
}
int CBirthdays::Index(HANDLE hContact) const
{
- int i;
- for (i = 0; i < count; i++)
- {
- if (birthdays[i]->hContact == hContact)
- {
- return i;
- }
- }
+ for (int i = 0; i < count; i++)
+ if (birthdays[i]->hContact == hContact)
+ return i;
+
return -1;
}
@@ -163,8 +145,7 @@ HANDLE CBirthdays::GetClistIcon(HANDLE hContact) const
{
int index = Index(hContact);
if ((index >= 0) && (index < count))
- {
- return birthdays[index]->hClistIcon;
- }
- return (HANDLE) -1;
-} \ No newline at end of file
+ return birthdays[index]->hClistIcon;
+
+ return INVALID_HANDLE_VALUE;
+}
diff --git a/plugins/WhenWasIt/src/commonheaders.h b/plugins/WhenWasIt/src/commonheaders.h
index 8ad1db0be8..9576d787c1 100644
--- a/plugins/WhenWasIt/src/commonheaders.h
+++ b/plugins/WhenWasIt/src/commonheaders.h
@@ -33,40 +33,38 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <time.h>
#include <math.h>
+#include <newpluginapi.h>
+#include <m_database.h>
+#include <m_system.h>
+#include <m_skin.h>
+#include <m_options.h>
+#include <m_clist.h>
+#include <m_langpack.h>
+#include <m_history.h>
+#include <m_contacts.h>
+#include <m_popup.h>
+#include <m_fontservice.h>
+#include <m_utils.h>
+#include <m_icolib.h>
+#include <m_cluiframes.h>
+#include <m_clui.h>
+#include <m_protosvc.h>
+#include <m_hotkeys.h>
+#include <m_toptoolbar.h>
+#include <m_metacontacts.h>
+#include <m_message.h>
+#include <m_extraicons.h>
+#include <win2k.h>
+
+#include "icons.h"
#include "resource.h"
#include "version.h"
#include "utils.h"
#include "date_utils.h"
#include "services.h"
-//#include "events.h"
#include "hooked_events.h"
-#include "icons.h"
#include "notifiers.h"
-//#include "birthdays.h"
-#include "win2k.h"
-#include "newpluginapi.h"
-#include "m_database.h"
-#include "m_system.h"
-#include "m_skin.h"
-#include "m_options.h"
-#include "m_clist.h"
-#include "m_langpack.h"
-#include "m_history.h"
-#include "m_contacts.h"
-#include "m_popup.h"
-//#include "m_popupw.h"
-#include "m_fontservice.h"
-#include "m_utils.h"
-#include "m_icolib.h"
-#include "m_cluiframes.h"
-#include "m_clui.h"
-#include "m_protosvc.h"
-#include "m_hotkeys.h"
-#include "m_toptoolbar.h"
-#include "m_metacontacts.h"
-#include "m_message.h"
-#include "m_extraicons.h"
extern char ModuleName[];
extern HINSTANCE hInstance;
diff --git a/plugins/WhenWasIt/src/dlg_handlers.cpp b/plugins/WhenWasIt/src/dlg_handlers.cpp
index 3f7f0f25cf..dae746417c 100644
--- a/plugins/WhenWasIt/src/dlg_handlers.cpp
+++ b/plugins/WhenWasIt/src/dlg_handlers.cpp
@@ -394,18 +394,19 @@ INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ HANDLE hContact = (HANDLE)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+
switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hWnd);
+ TranslateDialogDefault(hWnd);
+ SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam);
- SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiAddBirthdayContact);
- int i;
- for (i = 0; i < cSaveModule; i++)
+ SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(hAddBirthdayContact, 1));
+ {
+ for (int i = 0; i < cSaveModule; i++)
SendMessage(GetDlgItem(hWnd, IDC_COMPATIBILITY), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szSaveModule[i]));
- i = commonData.cDefaultModule;
- SendMessage(GetDlgItem(hWnd, IDC_COMPATIBILITY), CB_SETCURSEL, i, 0);
+ SendMessage(GetDlgItem(hWnd, IDC_COMPATIBILITY), CB_SETCURSEL, commonData.cDefaultModule, 0);
}
break;
@@ -414,11 +415,10 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
int year, month, day;
TCHAR *szTooltipText = TranslateT("Please select the module where you want the date of birth to be saved.\r\n\"UserInfo\" is the default location.\r\nUse \"Protocol module\" to make the data visible in User Details.\n\"mBirthday module\" uses the same module as mBirthday plugin.");
TCHAR *szCurrentModuleTooltip = NULL;
- HANDLE hContact = (HANDLE) GetWindowLongPtr(hWnd, GWLP_USERDATA);
const int maxSize = 2048;
TCHAR buffer[maxSize];
- char *protocol = GetContactProto(hContact);
- TCHAR *name = GetContactName(hContact, protocol);
+ char *szProto = GetContactProto(hContact);
+ TCHAR *name = GetContactName(hContact, szProto);
_stprintf(buffer, TranslateT("Set birthday for %s:"), name);
free(name);
SetWindowText(hWnd, buffer);
@@ -441,7 +441,7 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
case DOB_PROTOCOL:
DateTime_SetMonthCalColor(hDate, MCSC_TITLEBK, COLOR_PROTOCOL);
- _stprintf(buffer, TranslateT("%S protocol"), protocol);
+ _stprintf(buffer, TranslateT("%S szProto"), szProto);
szCurrentModuleTooltip = buffer;
break;
@@ -473,11 +473,9 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
}
case WM_DESTROY:
- {
- HANDLE hContact = (HANDLE) GetWindowLongPtr(hWnd, GWLP_USERDATA);
- OnExtraImageApply((WPARAM) hContact, NULL); //the birthday might be changed, refresh icon.
- WindowList_Remove(hAddBirthdayWndsList, hWnd);
- }
+ RefreshContactListIcons(hContact); //the birthday might be changed, refresh icon.
+ Skin_ReleaseIcon((HICON)SendMessage(hWnd, WM_GETICON, ICON_BIG, 0));
+ WindowList_Remove(hAddBirthdayWndsList, hWnd);
break;
case WM_CLOSE:
@@ -519,34 +517,16 @@ void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOW
#define NA TranslateT("N/A")
-TCHAR *GetBirthdayModule(int module, HANDLE hContact, TCHAR *birthdayModule, int size)
+TCHAR *GetBirthdayModule(int module, HANDLE hContact)
{
switch (module) {
- case DOB_MBIRTHDAY:
- _tcsncpy(birthdayModule, _T("mBirthday"), size);
- break;
-
- case DOB_PROTOCOL:
- _sntprintf(birthdayModule, size, TranslateT("%S protocol"), GetContactProto(hContact));
- break;
-
- case DOB_BIRTHDAYREMINDER:
- _tcsncpy(birthdayModule, _T("Birthday Reminder"), size);
- break;
-
- case DOB_USERINFO:
- _tcsncpy(birthdayModule, _T("UserInfo"), size);
- break;
-
- case DOB_MICQBIRTHDAY:
- _tcsncpy(birthdayModule, _T("mICQBirthday"), size);
- break;
-
- default:
- _tcsncpy(birthdayModule, NA, size);
- break;
+ case DOB_MBIRTHDAY: return _T("mBirthday");
+ case DOB_PROTOCOL: return TranslateT("Protocol module");
+ case DOB_BIRTHDAYREMINDER: return _T("Birthday Reminder");
+ case DOB_USERINFO: return _T("UserInfo");
+ case DOB_MICQBIRTHDAY: return _T("mICQBirthday");
}
- return birthdayModule;
+ return NA;
}
static int lastColumn = -1;
@@ -586,20 +566,9 @@ INT_PTR CALLBACK BirthdaysCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam
return res;
}
-//only updates the birthday part of the list view entry. Won't update the protocol and the contact name (those shouldn't change anyway :))
+//only updates the birthday part of the list view entry. Won't update the szProto and the contact name (those shouldn't change anyway :))
int UpdateBirthdayEntry(HWND hList, HANDLE hContact, int entry, int bShowAll, int bShowCurrentAge, int bAdd)
{
- const int maxSize = 2048;
- TCHAR buffer[maxSize];
-
- int age;
- int dtb;
- int year, month, day;
- TCHAR *name;
- int module;
- char *protocol;
- LVITEM item = {0};
-
int currentYear;
int currentMonth;
int currentDay;
@@ -614,35 +583,35 @@ int UpdateBirthdayEntry(HWND hList, HANDLE hContact, int entry, int bShowAll, in
currentYear = today->tm_year;
}
- item.mask = LVIF_TEXT | LVIF_PARAM;
- item.iItem = entry;
-
- module = GetContactDOB(hContact, year, month, day);
+ int year, month, day;
+ int module = GetContactDOB(hContact, year, month, day);
if (bShowAll || IsDOBValid(year, month, day)) {
lastColumn = -1; //list isn't sorted anymore
- dtb = DaysToBirthday(Today(), year, month, day);
- age = GetContactAge(hContact);
+ int dtb = DaysToBirthday(Today(), year, month, day);
+ int age = GetContactAge(hContact);
if (bShowCurrentAge)
if ((month > currentMonth) || ((month == currentMonth) && (day > currentDay))) //birthday still to come
age--;
- item.lParam = (LPARAM) hContact;
-
- protocol = GetContactProto(hContact);
-
- MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, protocol, -1, buffer, maxSize);
+ char *szProto = GetContactProto(hContact);
+ PROTOACCOUNT *pAcc = ProtoGetAccount(szProto);
- item.pszText = buffer;
+ LVITEM item = {0};
+ item.mask = LVIF_TEXT | LVIF_PARAM;
+ item.iItem = entry;
+ item.lParam = (LPARAM) hContact;
+ item.pszText = pAcc->tszAccountName;
if (bAdd)
ListView_InsertItem(hList, &item);
else
- ListView_SetItemText(hList, entry, 0, buffer);
+ ListView_SetItemText(hList, entry, 0, pAcc->tszAccountName);
- name = GetContactName(hContact, protocol);
+ TCHAR *name = GetContactName(hContact, szProto);
ListView_SetItemText(hList, entry, 1, name);
free(name);
+ TCHAR buffer[2048];
if ((dtb <= 366) && (dtb >= 0))
_stprintf(buffer, _T("%d"), dtb);
else
@@ -662,13 +631,11 @@ int UpdateBirthdayEntry(HWND hList, HANDLE hContact, int entry, int bShowAll, in
_stprintf(buffer, NA);
ListView_SetItemText(hList, entry, 4, buffer);
-
- GetBirthdayModule(module, hContact, buffer, maxSize);
- ListView_SetItemText(hList, entry, 5, buffer);
+ ListView_SetItemText(hList, entry, 5, GetBirthdayModule(module, hContact));
res++;
}
- else if ((!bShowAll) && (!bAdd))
+ else if (!bShowAll && !bAdd)
ListView_DeleteItem(hList, entry);
return res;
@@ -734,9 +701,9 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
{
switch (msg) {
case WM_INITDIALOG:
+ TranslateDialogDefault(hWnd);
+ SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(hListMenu));
{
- TranslateDialogDefault(hWnd);
- SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiListMenu);
HWND hList = GetDlgItem(hWnd, IDC_BIRTHDAYS_LIST);
ListView_SetExtendedListViewStyleEx(hList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
@@ -776,12 +743,6 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
}
return TRUE;
- case WM_DESTROY:
- hBirthdaysDlg = NULL;
- Utils_SaveWindowPosition(hWnd,NULL,ModuleName,"BirthdayList");
- lastColumn = -1;
- break;
-
case WM_CLOSE:
DestroyWindow(hWnd);
break;
@@ -864,6 +825,14 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
}
}
break;
+
+ case WM_DESTROY:
+ hBirthdaysDlg = NULL;
+ Utils_SaveWindowPosition(hWnd,NULL,ModuleName,"BirthdayList");
+ Skin_ReleaseIcon((HICON)SendMessage(hWnd, WM_GETICON, ICON_BIG, 0));
+ lastColumn = -1;
+ break;
+
}
return 0;
}
@@ -897,7 +866,7 @@ INT_PTR CALLBACK DlgProcUpcoming(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
{
timeout = commonData.cDlgTimeout;
TranslateDialogDefault(hWnd);
- SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiListMenu);
+ SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(hListMenu));
HWND hList = GetDlgItem(hWnd, IDC_UPCOMING_LIST);
ListView_SetExtendedListViewStyleEx(hList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
@@ -932,11 +901,6 @@ INT_PTR CALLBACK DlgProcUpcoming(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
DestroyWindow(hWnd);
break;
- case WM_DESTROY:
- hUpcomingDlg = NULL;
- KillTimer(hWnd, UPCOMING_TIMER_ID);
- break;
-
case WWIM_ADD_UPCOMING_BIRTHDAY:
{
PUpcomingBirthday data = (PUpcomingBirthday) wParam;
@@ -965,6 +929,12 @@ INT_PTR CALLBACK DlgProcUpcoming(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
SendMessage(hWnd, WM_CLOSE, 0, 0);
break;
}
+
+ case WM_DESTROY:
+ hUpcomingDlg = NULL;
+ Skin_ReleaseIcon((HICON)SendMessage(hWnd, WM_GETICON, ICON_BIG, 0));
+ KillTimer(hWnd, UPCOMING_TIMER_ID);
+ break;
}
return 0;
@@ -975,7 +945,6 @@ DWORD WINAPI OpenMessageWindowThread(void *data)
HANDLE hContact = (HANDLE) data;
CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM) hContact, 0);
CallServiceSync("SRMsg/LaunchMessageWindow", (WPARAM) hContact, 0);
-
return 0;
}
diff --git a/plugins/WhenWasIt/src/hooked_events.cpp b/plugins/WhenWasIt/src/hooked_events.cpp
index fc47b37771..f9ea5641a8 100644
--- a/plugins/WhenWasIt/src/hooked_events.cpp
+++ b/plugins/WhenWasIt/src/hooked_events.cpp
@@ -26,15 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EXCLUDE_HIDDEN 1
#define EXCLUDE_IGNORED 2
-HANDLE hModulesLoaded;
-HANDLE hOptionsInitialize;
-HANDLE hIconsChanged;
-HANDLE hExtraIconListRebuild;
-HANDLE hExtraImageApply;
-HANDLE hContactSettingChanged;
-HANDLE hTopToolBarModuleLoaded;
-//HANDLE hContactSendMessage;
-
HANDLE hmCheckBirthdays = NULL;
HANDLE hmBirthdayList = NULL;
HANDLE hmRefreshDetails = NULL;
@@ -49,76 +40,61 @@ int currentDay;
int HookEvents()
{
- Log("%s", "Entering function " __FUNCTION__);
- hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
- hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise);
- Log("%s", "Leaving function " __FUNCTION__);
-
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise);
return 0;
}
int UnhookEvents()
{
- Log("%s", "Entering function " __FUNCTION__);
- UnhookEvent(hModulesLoaded);
- UnhookEvent(hOptionsInitialize);
- UnhookEvent(hIconsChanged);
- UnhookEvent(hExtraIconListRebuild);
- UnhookEvent(hExtraImageApply);
- UnhookEvent(hContactSettingChanged);
- UnhookEvent(hTopToolBarModuleLoaded);
-
KillTimers();
-
- Log("%s", "Leaving function " __FUNCTION__);
-
return 0;
}
int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
- hIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, OnIconsChanged);
- hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnContactSettingChanged);
- hTopToolBarModuleLoaded = HookEvent(ME_TTB_MODULELOADED, OnTopToolBarModuleLoaded);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnContactSettingChanged);
+ HookEvent(ME_TTB_MODULELOADED, OnTopToolBarModuleLoaded);
SkinAddNewSoundEx(BIRTHDAY_NEAR_SOUND, LPGEN("WhenWasIt"), LPGEN("Birthday near"));
SkinAddNewSoundEx(BIRTHDAY_TODAY_SOUND, LPGEN("WhenWasIt"), LPGEN("Birthday today"));
UpdateTimers();
- CLISTMENUITEM cl = {0};
- cl.cbSize = sizeof(CLISTMENUITEM);
- cl.hIcon = hiCheckMenu;
+ CLISTMENUITEM cl = { sizeof(cl) };
cl.position = 10000000;
+ cl.flags = CMIF_ICONFROMICOLIB;
+ cl.pszPopupName = "Birthdays (When Was It)";
+
cl.pszService = MS_WWI_CHECK_BIRTHDAYS;
+ cl.icolibItem = hCheckMenu;
cl.pszName = "Check for birthdays";
- cl.pszPopupName = "Birthdays (When Was It)";
hmCheckBirthdays = Menu_AddMainMenuItem(&cl);
cl.pszService = MS_WWI_LIST_SHOW;
cl.pszName = "Birthday list";
- cl.hIcon = hiListMenu;
+ cl.icolibItem = hListMenu;
hmBirthdayList = Menu_AddMainMenuItem(&cl);
cl.pszService = MS_WWI_REFRESH_USERDETAILS;
cl.position = 10100000;
cl.pszName = "Refresh user details";
- cl.hIcon = hiRefreshUserDetails;
+ cl.icolibItem = hRefreshUserDetails;
hmRefreshDetails = Menu_AddMainMenuItem(&cl);
cl.pszService = MS_WWI_IMPORT_BIRTHDAYS;
cl.position = 10200000;
cl.pszName = "Import birthdays";
- cl.hIcon = hiImportBirthdays;
+ cl.icolibItem = hImportBirthdays;
hmImportBirthdays = Menu_AddMainMenuItem(&cl);
cl.pszService = MS_WWI_EXPORT_BIRTHDAYS;
cl.pszName = "Export birthdays";
- cl.hIcon = hiExportBirthdays;
+ cl.icolibItem = hExportBirthdays;
hmExportBirthdays = Menu_AddMainMenuItem(&cl);
cl.pszService = MS_WWI_ADD_BIRTHDAY;
cl.position = 10000000;
- cl.hIcon = hiAddBirthdayContact;
+ cl.icolibItem = hAddBirthdayContact;
cl.pszName = "Add/change user &birthday";
hmAddChangeBirthday = Menu_AddContactMenuItem(&cl);
@@ -146,7 +122,7 @@ int OnTopToolBarModuleLoaded(WPARAM wParam, LPARAM lParam)
ttb.cbSize = sizeof(ttb);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
ttb.pszService = MS_WWI_CHECK_BIRTHDAYS;
- ttb.hIconUp = hiCheckMenu;
+ ttb.hIconHandleUp = hCheckMenu;
ttb.name = ttb.pszTooltipUp = LPGEN("Check for birthdays");
TopToolbar_AddButton(&ttb);
return 0;
@@ -170,51 +146,18 @@ int OnOptionsInitialise(WPARAM wParam, LPARAM lParam)
return 0;
}
-void UpdateMenuItems()
-{
- CLISTMENUITEM cl = {0};
- cl.cbSize = sizeof(CLISTMENUITEM);
- cl.flags = CMIM_ICON;
- cl.hIcon = hiCheckMenu;
- int res = CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hmCheckBirthdays, (LPARAM) &cl);
-
- cl.hIcon = hiListMenu;
- res = CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hmBirthdayList, (LPARAM) &cl);
-
- cl.hIcon = hiRefreshUserDetails;
- res = CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hmRefreshDetails, (LPARAM) &cl);
-
- cl.hIcon = hiAddBirthdayContact;
- res = CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hmAddChangeBirthday, (LPARAM) &cl);
-
- cl.hIcon = hiImportBirthdays;
- res = CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hmImportBirthdays, (LPARAM) &cl);
-
- cl.hIcon = hiExportBirthdays;
- res = CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hmExportBirthdays, (LPARAM) &cl);
-}
-
-int OnIconsChanged(WPARAM wParam, LPARAM lParam)
-{
- GetIcons();
- UpdateMenuItems();
-
- return 0;
-}
-
int OnContactSettingChanged(WPARAM wParam, LPARAM lParam)
{
DBCONTACTWRITESETTING *dw = (DBCONTACTWRITESETTING *) lParam;
DBVARIANT dv = dw->value;
if ((strcmp(dw->szModule, DUMMY_MODULE) == 0) && (strcmp(dw->szSetting, DUMMY_SETTING) == 0))
- OnExtraImageApply(wParam, 0);
+ RefreshContactListIcons((HANDLE)wParam);
return 0;
}
-int OnExtraImageApply(WPARAM wParam, LPARAM lParam)
+int RefreshContactListIcons(HANDLE hContact)
{
- HANDLE hContact = (HANDLE) wParam;
if (hContact == 0)
return 0;
@@ -260,9 +203,9 @@ int OnExtraImageApply(WPARAM wParam, LPARAM lParam)
}
if (dtb >= 0)
- ClistIconNotifyBirthday(hContact, dtb);
+ ExtraIcon_SetIcon(hWWIExtraIcons, hContact, GetDTBIconHandle(dtb));
}
- else ClearClistIcon(hContact);
+ else ExtraIcon_Clear(hWWIExtraIcons, hContact);
return 0;
}
@@ -285,7 +228,6 @@ int UpdateTimers()
int KillTimers()
{
- Log("%s", "Entering function " __FUNCTION__);
if (hCheckTimer) {
KillTimer(NULL, hCheckTimer);
hCheckTimer = NULL;
@@ -296,31 +238,22 @@ int KillTimers()
hDateChangeTimer = NULL;
}
- Log("%s", "Leaving function " __FUNCTION__);
return 0;
}
VOID CALLBACK OnCheckTimer(HWND hWnd, UINT msg, UINT_PTR idEvent, DWORD dwTime)
{
- Log("%s", "Entering function " __FUNCTION__);
CheckBirthdaysService(0, 1);
- Log("%s", "Leaving function " __FUNCTION__);
}
VOID CALLBACK OnDateChangeTimer(HWND hWnd, UINT msg, UINT_PTR idEvent, DWORD dwTime)
{
SYSTEMTIME now;
- //Log("%s", "Entering function " __FUNCTION__);
GetLocalTime(&now);
+
if (currentDay != now.wDay)
- {
- CheckBirthdaysService(0, 1);
- }
- //else{
- // RefreshAllContactListIcons();
- //}
+ CheckBirthdaysService(0, 1);
+
currentDay = now.wDay;
-
- //Log("%s", "Leaving function " __FUNCTION__);
}
diff --git a/plugins/WhenWasIt/src/hooked_events.h b/plugins/WhenWasIt/src/hooked_events.h
index 30e2c2455a..3b8ecc60ba 100644
--- a/plugins/WhenWasIt/src/hooked_events.h
+++ b/plugins/WhenWasIt/src/hooked_events.h
@@ -35,8 +35,6 @@ int UnhookEvents();
int OnModulesLoaded(WPARAM wParam, LPARAM lParam);
int OnTopToolBarModuleLoaded(WPARAM wParam, LPARAM lParam);
int OnOptionsInitialise(WPARAM wParam, LPARAM lParam);
-int OnIconsChanged(WPARAM wParam, LPARAM lParam);
-int OnExtraImageApply(WPARAM wParam, LPARAM lParam);
int OnContactSettingChanged(WPARAM wParam, LPARAM lParam);
int UpdateTimers();
diff --git a/plugins/WhenWasIt/src/icons.cpp b/plugins/WhenWasIt/src/icons.cpp
index d8099345f0..14db9fbd71 100644
--- a/plugins/WhenWasIt/src/icons.cpp
+++ b/plugins/WhenWasIt/src/icons.cpp
@@ -21,160 +21,61 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
#include "icons.h"
-//HICON hiDlg = NULL;
-HICON hiMainMenu = NULL;
-HICON hiCheckMenu = NULL;
-HICON hiListMenu = NULL;
-HICON hiAddBirthdayContact = NULL;
-HICON hiRefreshUserDetails = NULL;
-
-HICON hiImportBirthdays = NULL;
-HICON hiExportBirthdays = NULL;
+HANDLE hCheckMenu, hListMenu, hAddBirthdayContact, hRefreshUserDetails;
+HANDLE hImportBirthdays, hExportBirthdays;
const int cDTB = 10;
-HICON hiDTB[cDTB] = {NULL};
-HICON hiDTBMore = NULL;
-
-HANDLE hClistImages[cDTB + 1];
+HANDLE hDTB[cDTB] = {NULL};
+HANDLE hDTBMore = NULL;
HANDLE hWWIExtraIcons = (HANDLE) -1;
-#define GET_DTB_ICON(index) (hiDTB[index] = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DTB ## index)))
-
-int LoadIcons()
-{
- //hiDlgIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_BIRTHDAYS_DLG));
- hiCheckMenu = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CHECK));
- hiListMenu = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_LIST));
- hiAddBirthdayContact = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ADD));
- hiRefreshUserDetails = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REFRESH_USERDETAILS));
-
- hiImportBirthdays = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_IMPORT_BIRTHDAYS));
- hiExportBirthdays = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXPORT_BIRTHDAYS));
-
- GET_DTB_ICON(0);
- GET_DTB_ICON(1);
- GET_DTB_ICON(2);
- GET_DTB_ICON(3);
- GET_DTB_ICON(4);
- GET_DTB_ICON(5);
- GET_DTB_ICON(6);
- GET_DTB_ICON(7);
- GET_DTB_ICON(8);
- GET_DTB_ICON(9);
- hiDTBMore = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DTBMORE));
-
- AddIcons();
- GetIcons();
-
- hWWIExtraIcons = ExtraIcon_Register("WhenWasIt", Translate("WhenWasIt birthday reminder"), "MenuCheck");
- return 0;
-}
-
-HANDLE AddIcon(HICON icon, char *name, char *description)
+static HANDLE AddIcon(char *name, char *description, TCHAR *tszPath, int iDefaultIdx)
{
- SKINICONDESC sid = {0};
- sid.cbSize = sizeof(sid);
+ SKINICONDESC sid = { sizeof(sid) };
+ sid.flags = SIDF_PATH_UNICODE;
sid.pszSection = "WhenWasIt";
sid.cx = sid.cy = 16;
sid.pszDescription = description;
sid.pszName = name;
- sid.hDefaultIcon = icon;
+ sid.ptszDefaultFile = tszPath;
+ sid.iDefaultIndex = -iDefaultIdx;
return Skin_AddIcon(&sid);
}
int AddIcons()
{
- AddIcon(hiCheckMenu, "MenuCheck", "Check birthdays menu item");
- AddIcon(hiListMenu, "MenuList", "List birthdays menu item");
- AddIcon(hiAddBirthdayContact, "AddBirthday", "Add/change birthday");
- AddIcon(hiRefreshUserDetails, "RefreshUserDetails", "Refresh user details");
+ TCHAR tszPath[MAX_PATH];
+ GetModuleFileName(hInstance, tszPath, SIZEOF(tszPath));
+
+ hCheckMenu = AddIcon("MenuCheck", "Check birthdays menu item", tszPath, IDI_CHECK);
+ hListMenu = AddIcon("MenuList", "List birthdays menu item", tszPath, IDI_LIST);
+ hAddBirthdayContact = AddIcon("AddBirthday", "Add/change birthday", tszPath, IDI_ADD);
+ hRefreshUserDetails = AddIcon("RefreshUserDetails", "Refresh user details", tszPath, IDI_REFRESH_USERDETAILS);
- AddIcon(hiImportBirthdays, "ImportBirthdays", "Import birthdays");
- AddIcon(hiExportBirthdays, "ExportBirthdays", "Export birthdays");
+ hImportBirthdays = AddIcon("ImportBirthdays", "Import birthdays", tszPath, IDI_IMPORT_BIRTHDAYS);
+ hExportBirthdays = AddIcon("ExportBirthdays", "Export birthdays", tszPath, IDI_EXPORT_BIRTHDAYS);
char name[1024];
char description[1024];
- AddIcon(hiDTB[0], "DTB0", "Birthday today");
- AddIcon(hiDTB[1], "DTB1", "1 day to birthday");
+ hDTB[0] = AddIcon("DTB0", "Birthday today", tszPath, IDI_DTB0);
+ hDTB[1] = AddIcon("DTB1", "1 day to birthday", tszPath, IDI_DTB1);
for (int i = 2; i < cDTB; i++) {
sprintf(name, "DTB%d", i);
sprintf(description, "%d days to birthday", i);
- AddIcon(hiDTB[i], name, description);
+ hDTB[i] = AddIcon(name, description, tszPath, IDI_DTB0+i);
}
sprintf(description, "More than %d days to birthday", cDTB - 1);
- AddIcon(hiDTBMore, "DTBMore", description);
- return 0;
-}
-
-HICON GetIcon(char *name)
-{
- return Skin_GetIcon(name);
-}
-
-void FreeIcon(HICON &icon)
-{
- DestroyIcon(icon);
- icon = NULL;
-}
+ hDTBMore = AddIcon("DTBMore", description, tszPath, IDI_DTBMORE);
-void FreeIcons()
-{
- static int bFreed = 0;
- if ( !bFreed) {
- FreeIcon(hiCheckMenu);
- FreeIcon(hiListMenu);
- FreeIcon(hiAddBirthdayContact);
- FreeIcon(hiRefreshUserDetails);
-
- FreeIcon(hiImportBirthdays);
- FreeIcon(hiExportBirthdays);
-
- for (int i = 0; i < cDTB; i++)
- FreeIcon(hiDTB[i]);
-
- FreeIcon(hiDTBMore);
- }
- bFreed = 1; //only free them once (ours).
-}
-
-int GetIcons()
-{
- hiCheckMenu = GetIcon("MenuCheck");
- hiListMenu = GetIcon("MenuList");
- hiAddBirthdayContact = GetIcon("AddBirthday");
- hiRefreshUserDetails = GetIcon("RefreshUserDetails");
-
- hiImportBirthdays = GetIcon("ImportBirthdays");
- hiExportBirthdays = GetIcon("ExportBirthdays");
-
- char buffer[1024];
- for (int i = 0; i < cDTB; i++)
- {
- sprintf(buffer, "DTB%d", i);
- hiDTB[i] = GetIcon(buffer);
- }
- hiDTBMore = GetIcon("DTBMore");
+ hWWIExtraIcons = ExtraIcon_Register("WhenWasIt", "WhenWasIt birthday reminder", "MenuCheck");
return 0;
}
-HICON GetDTBIcon(int dtb)
-{
- if ((dtb >= cDTB) || (dtb < 0))
- return hiDTBMore;
-
- return hiDTB[dtb];
-}
-
-HICON GetDABIcon(int dab)
-{
- return GetDTBIcon(dab);
-}
-
-HANDLE GetClistIcon(int dtb)
+HANDLE GetDTBIconHandle(int dtb)
{
- if (dtb >= cDTB)
- return hClistImages[cDTB];
+ if (dtb >= cDTB || dtb < 0)
+ return hDTBMore;
- return hClistImages[dtb];
+ return hDTB[dtb];
}
diff --git a/plugins/WhenWasIt/src/icons.h b/plugins/WhenWasIt/src/icons.h
index d3f312fe46..d5c3320926 100644
--- a/plugins/WhenWasIt/src/icons.h
+++ b/plugins/WhenWasIt/src/icons.h
@@ -21,28 +21,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef M_WWI_ICONS_H
#define M_WWI_ICONS_H
-extern HICON hiMainMenu;
-extern HICON hiCheckMenu;
-extern HICON hiListMenu;
-extern HICON hiAddBirthdayContact;
-extern HICON hiRefreshUserDetails;
+extern HANDLE hCheckMenu;
+extern HANDLE hListMenu;
+extern HANDLE hAddBirthdayContact;
+extern HANDLE hRefreshUserDetails;
-extern HICON hiImportBirthdays;
-extern HICON hiExportBirthdays;
+extern HANDLE hImportBirthdays;
+extern HANDLE hExportBirthdays;
-extern HICON hiDTB[];
-extern HICON hiDTBMore;
-
-extern HANDLE hClistImages[];
+extern HANDLE hDTB[];
+extern HANDLE hDTBMore;
extern HANDLE hWWIExtraIcons;
-int LoadIcons();
int AddIcons();
-int GetIcons();
-HICON GetDTBIcon(int dtb);
-HICON GetDABIcon(int dtb);
-HANDLE GetClistIcon(int dtb);
+HANDLE GetDTBIconHandle(int dtb);
+
+__forceinline HICON GetDTBIcon(int dtb)
+{ return Skin_GetIconByHandle( GetDTBIconHandle(dtb));
+}
#endif //M_WWI_ICONS_H \ No newline at end of file
diff --git a/plugins/WhenWasIt/src/notifiers.cpp b/plugins/WhenWasIt/src/notifiers.cpp
index 0c82dfadfc..f05ae5f1eb 100644
--- a/plugins/WhenWasIt/src/notifiers.cpp
+++ b/plugins/WhenWasIt/src/notifiers.cpp
@@ -30,7 +30,7 @@ void FillPopupData(POPUPDATAT &pd, int dtb)
pd.iSeconds = popupTimeout;
}
-int PopupNotifyNoBirthdays()
+void PopupNotifyNoBirthdays()
{
POPUPDATAT pd = {0};
FillPopupData(pd, -1);
@@ -38,7 +38,9 @@ int PopupNotifyNoBirthdays()
_tcscpy(pd.lptzContactName, TranslateT("WhenWasIt"));
_tcscpy(pd.lptzText, TranslateT("No upcoming birthdays."));
- return PUAddPopUpT(&pd);
+ PUAddPopUpT(&pd);
+
+ Skin_ReleaseIcon(pd.lchIcon);
}
TCHAR *BuildDTBText(int dtb, TCHAR *name, TCHAR *text, int size)
@@ -86,13 +88,8 @@ int PopupNotifyBirthday(HANDLE hContact, int dtb, int age)
FillPopupData(pd, dtb);
pd.lchContact = hContact;
pd.PluginWindowProc = (WNDPROC) DlgProcPopup;
- //pd.PluginData = (void *) hContact;
- //pd.colorBack = background;
- //pd.colorText = foreground;
- //pd.iSeconds = popupTimeout;
pd.lchIcon = GetDTBIcon(dtb);
- //strcpy(pd.lpzContactName, text);
_stprintf(pd.lptzContactName, TranslateT("Birthday - %s"), name);
TCHAR *sex;
switch (toupper(gender)) {
@@ -112,6 +109,7 @@ int PopupNotifyBirthday(HANDLE hContact, int dtb, int age)
_stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age);
PUAddPopUpT(&pd);
+ Skin_ReleaseIcon(pd.lchIcon);
free(name);
return 0;
@@ -135,7 +133,7 @@ int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age)
FillPopupData(pd, dab);
pd.lchContact = hContact;
pd.PluginWindowProc = (WNDPROC) DlgProcPopup;
- pd.lchIcon = GetDABIcon(dab);
+ pd.lchIcon = GetDTBIcon(dab);
_stprintf(pd.lptzContactName, TranslateT("Birthday - %s"), name);
TCHAR *sex;
@@ -156,14 +154,9 @@ int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age)
_stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age);
PUAddPopUpT(&pd);
- free(name);
-
- return 0;
-}
-int ClistIconNotifyBirthday(HANDLE hContact, int dtb)
-{
- ExtraIcon_SetIcon(hWWIExtraIcons, hContact, "MenuCheck");
+ Skin_ReleaseIcon(pd.lchIcon);
+ free(name);
return 0;
}
@@ -229,17 +222,6 @@ int SoundNotifyBirthday(int dtb)
return 0;
}
-int ClearClistIcon(HANDLE hContact)
-{
- return ExtraIcon_Clear(hWWIExtraIcons, hContact);
-}
-
-int RefreshContactListIcons(HANDLE hContact)
-{
- OnExtraImageApply((WPARAM) hContact, 0);
- return 0;
-}
-
//if oldClistIcon != -1 it will remove the old location of the clist extra icon
//called with oldClistIcon != -1 from dlg_handlers whtn the extra icon slot changes.
int RefreshAllContactListIcons(int oldClistIcon)
@@ -247,7 +229,7 @@ int RefreshAllContactListIcons(int oldClistIcon)
HANDLE hContact = db_find_first();
while (hContact != NULL) {
if (oldClistIcon != -1)
- ClearClistIcon(hContact);
+ ExtraIcon_Clear(hWWIExtraIcons, hContact);
RefreshContactListIcons(hContact); //will change bBirthdayFound if needed
hContact = db_find_next(hContact);
diff --git a/plugins/WhenWasIt/src/notifiers.h b/plugins/WhenWasIt/src/notifiers.h
index 149cd6a3bb..62f6dd4b4e 100644
--- a/plugins/WhenWasIt/src/notifiers.h
+++ b/plugins/WhenWasIt/src/notifiers.h
@@ -44,17 +44,14 @@ struct TUpcomingBirthday{
typedef TUpcomingBirthday *PUpcomingBirthday;
-int PopupNotifyNoBirthdays();
-int PopupNotifyBirthday(HANDLE hContact, int dtb, int age);
-int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age);
-int DialogNotifyBirthday(HANDLE hContact, int dtb, int age);
-int DialogNotifyMissedBirthday(HANDLE hContact, int dab, int age);
-int SoundNotifyBirthday(int dtb);
-
-int ClistIconNotifyBirthday(HANDLE hContact, int dtb);
-int ClearClistIcon(HANDLE hContact);
-
-int RefreshContactListIcons(HANDLE hContact);
-int RefreshAllContactListIcons(int oldClistIcon = -1);
+void PopupNotifyNoBirthdays();
+int PopupNotifyBirthday(HANDLE hContact, int dtb, int age);
+int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age);
+int DialogNotifyBirthday(HANDLE hContact, int dtb, int age);
+int DialogNotifyMissedBirthday(HANDLE hContact, int dab, int age);
+int SoundNotifyBirthday(int dtb);
+
+int RefreshContactListIcons(HANDLE hContact);
+int RefreshAllContactListIcons(int oldClistIcon = -1);
#endif //M_WWI_NOTIFIERS_H \ No newline at end of file
diff --git a/plugins/WhenWasIt/src/resource.h b/plugins/WhenWasIt/src/resource.h
index 2df37cf7f3..ac0fbcbee7 100644
--- a/plugins/WhenWasIt/src/resource.h
+++ b/plugins/WhenWasIt/src/resource.h
@@ -7,17 +7,17 @@
#define IDI_BIRTHDAYS_DLG 102
#define IDD_BIRTHDAYS 104
#define IDI_CHECK 106
-#define IDI_LIST 107
+#define IDI_DTB0 107
#define IDI_DTB1 108
-#define IDI_DTB9 109
-#define IDI_DTB2 110
-#define IDI_DTB3 111
-#define IDI_DTB4 112
-#define IDI_DTB5 113
-#define IDI_DTB6 114
-#define IDI_DTB7 115
-#define IDI_DTB8 116
-#define IDI_DTB0 117
+#define IDI_DTB2 109
+#define IDI_DTB3 110
+#define IDI_DTB4 111
+#define IDI_DTB5 112
+#define IDI_DTB6 113
+#define IDI_DTB7 114
+#define IDI_DTB8 115
+#define IDI_DTB9 116
+#define IDI_LIST 117
#define IDI_DTBMORE 118
#define IDD_ADD_BIRTHDAY 119
#define IDI_ADD 121
diff --git a/plugins/WhenWasIt/src/services.cpp b/plugins/WhenWasIt/src/services.cpp
index 32241b33b9..170c9275d6 100644
--- a/plugins/WhenWasIt/src/services.cpp
+++ b/plugins/WhenWasIt/src/services.cpp
@@ -172,32 +172,28 @@ INT_PTR AddBirthdayService(WPARAM wParam, LPARAM lParam)
{
HWND hWnd = WindowList_Find(hAddBirthdayWndsList, (HANDLE) wParam);
if ( !hWnd) {
- hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_ADD_BIRTHDAY), NULL, DlgProcAddBirthday);
- if (hWnd == NULL) {
- TCHAR buffer[1024];
- _stprintf(buffer, _T("Error #%d while trying to create add birthday dialog"), GetLastError());
- MessageBox(0, buffer, _T("Error"), MB_OK);
- }
+ hWnd = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_ADD_BIRTHDAY), NULL, DlgProcAddBirthday, wParam);
WindowList_Add(hAddBirthdayWndsList, hWnd, (HANDLE) wParam);
- SetWindowLongPtr(hWnd, GWLP_USERDATA, wParam);
}
return ShowWindow(hWnd, SW_SHOW);
}
-void ShowPopupMessage(TCHAR *title, TCHAR *message, HICON icon)
+void ShowPopupMessage(TCHAR *title, TCHAR *message, HANDLE icon)
{
POPUPDATAT pd = {0};
- pd.lchIcon = icon;
+ pd.lchIcon = Skin_GetIconByHandle(icon);
_tcscpy(pd.lptzContactName, title);
_tcscpy(pd.lptzText, message);
pd.colorText = commonData.foreground;
pd.colorBack = commonData.background;
PUAddPopUpT(&pd);
+
+ Skin_ReleaseIcon(pd.lchIcon);
}
DWORD WINAPI RefreshUserDetailsWorkerThread(LPVOID param)
{
- ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Starting to refresh user details"), hiRefreshUserDetails);
+ ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Starting to refresh user details"), hRefreshUserDetails);
int delay = db_get_w(NULL, ModuleName, "UpdateDelay", REFRESH_DETAILS_DELAY);
int res;
@@ -208,7 +204,7 @@ DWORD WINAPI RefreshUserDetailsWorkerThread(LPVOID param)
if (hContact)
Sleep(delay); //sleep for a few seconds between requests
}
- ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done refreshing user details"), hiRefreshUserDetails);
+ ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done refreshing user details"), hRefreshUserDetails);
return 0;
}
@@ -245,9 +241,9 @@ INT_PTR ImportBirthdaysService(WPARAM wParam, LPARAM lParam)
if ( GetOpenFileName(&of)) {
TCHAR buffer[2048];
mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("Importing birthdays from file: %s"), fileName);
- ShowPopupMessage(TranslateT("WhenWasIt"), buffer, hiImportBirthdays);
+ ShowPopupMessage(TranslateT("WhenWasIt"), buffer, hImportBirthdays);
DoImport(fileName);
- ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done importing birthdays"), hiImportBirthdays);
+ ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done importing birthdays"), hImportBirthdays);
}
return 0;
@@ -273,9 +269,9 @@ INT_PTR ExportBirthdaysService(WPARAM wParam, LPARAM lParam)
_tcscat(fileName, _T(BIRTHDAY_EXTENSION));
_stprintf(buffer, TranslateT("Exporting birthdays to file: %s"), fileName);
- ShowPopupMessage(TranslateT("WhenWasIt"), buffer, hiExportBirthdays);
+ ShowPopupMessage(TranslateT("WhenWasIt"), buffer, hExportBirthdays);
DoExport(fileName);
- ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done exporting birthdays"), hiExportBirthdays);
+ ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done exporting birthdays"), hExportBirthdays);
}
return 0;
@@ -320,7 +316,7 @@ int DoImport(TCHAR *fileName)
else {
TCHAR tmp[2048];
_stprintf(tmp, TranslateT(NOTFOUND_FORMAT), szHandle, szProto);
- ShowPopupMessage(TranslateT("Warning"), tmp, hiImportBirthdays);
+ ShowPopupMessage(TranslateT("Warning"), tmp, hImportBirthdays);
}
}
}