From 696f4ea57845f48d6d979ecd9d66bb22bd9f738d Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Sun, 8 Jul 2012 20:51:14 +0000
Subject: TopToolbar usage fixed everywhere

git-svn-id: http://svn.miranda-ng.org/main/trunk@861 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 plugins/UserInfoEx/commonheaders.h         |  1 -
 plugins/UserInfoEx/dlg_anniversarylist.cpp | 24 ++-------------------
 plugins/UserInfoEx/dlg_anniversarylist.h   |  1 -
 plugins/UserInfoEx/init.cpp                | 31 ++++-----------------------
 plugins/UserInfoEx/svc_reminder.cpp        | 34 +++---------------------------
 plugins/UserInfoEx/svc_reminder.h          |  1 -
 6 files changed, 9 insertions(+), 83 deletions(-)

(limited to 'plugins/UserInfoEx')

diff --git a/plugins/UserInfoEx/commonheaders.h b/plugins/UserInfoEx/commonheaders.h
index e7b4f51bad..6501954a7b 100644
--- a/plugins/UserInfoEx/commonheaders.h
+++ b/plugins/UserInfoEx/commonheaders.h
@@ -107,7 +107,6 @@ typedef std::basic_string<TCHAR>	tstring;
 #include "m_flags.h"
 #include "m_metacontacts.h"
 #include "m_magneticwindows.h"
-#include "m_toolbar.h"
 #include "m_toptoolbar.h"
 #include "m_userinfoex.h"
 
diff --git a/plugins/UserInfoEx/dlg_anniversarylist.cpp b/plugins/UserInfoEx/dlg_anniversarylist.cpp
index 0ea9b5b645..827e4e7b78 100644
--- a/plugins/UserInfoEx/dlg_anniversarylist.cpp
+++ b/plugins/UserInfoEx/dlg_anniversarylist.cpp
@@ -1095,29 +1095,9 @@ VOID DlgAnniversaryListOnTopToolBarLoaded()
 	ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP | TTBBF_ICONBYHANDLE;
 	ttb.pszService = MS_USERINFO_REMINDER_LIST;
 	ttb.hIconHandleDn = ttb.hIconHandleUp = Skin_GetIconHandle(ICO_COMMON_ANNIVERSARY);
+	ttb.pszTooltipDn = ttb.pszTooltipUp = LPGEN("Anniversary list");
 	ttb.name = "Anniversary list";
-	CallService(MS_TTB_ADDBUTTON, (WPARAM) &ttb, 0);
-}
-
-/**
- * This function is called by the ME_TB_MODULELOADED event.
- * It adds a set of buttons to the Toolbar of the Modern Contact List.
- *
- * @param	wParam	- none
- *
- * @return	nothing
- **/
-VOID DlgAnniversaryListOnToolBarLoaded()
-{
-	TBButton tbb = { 0 };
-	tbb.cbSize = sizeof(tbb);
-	tbb.tbbFlags = TBBF_VISIBLE | TBBF_SHOWTOOLTIP;
-	tbb.defPos = 2100;
-	tbb.pszButtonName	= tbb.pszButtonID = TBB_IDBTN;
-	tbb.pszServiceName = MS_USERINFO_REMINDER_LIST;
-	tbb.pszTooltipDn = tbb.pszTooltipUp = LPGEN("Anniversary list");
-	tbb.hPrimaryIconHandle = tbb.hSecondaryIconHandle = Skin_GetIconHandle(ICO_COMMON_ANNIVERSARY);
-	CallService(MS_TB_ADDBUTTON, 0, (LPARAM) &tbb);
+	TopToolbar_AddButton(&ttb);
 }
 
 /**
diff --git a/plugins/UserInfoEx/dlg_anniversarylist.h b/plugins/UserInfoEx/dlg_anniversarylist.h
index 63d095a7ef..e7ff89e99c 100644
--- a/plugins/UserInfoEx/dlg_anniversarylist.h
+++ b/plugins/UserInfoEx/dlg_anniversarylist.h
@@ -38,7 +38,6 @@ Last change by : $Author: ing.u.horn $
 
 INT_PTR		DlgAnniversaryListShow(WPARAM wParam, LPARAM lParam);
 VOID		DlgAnniversaryListOnTopToolBarLoaded();
-VOID		DlgAnniversaryListOnToolBarLoaded();
 VOID		DlgAnniversaryListLoadModule();
 
 #endif /* _DLGANNIVERSARYLIST_H_ */
\ No newline at end of file
diff --git a/plugins/UserInfoEx/init.cpp b/plugins/UserInfoEx/init.cpp
index 514260af99..a36e828fe7 100644
--- a/plugins/UserInfoEx/init.cpp
+++ b/plugins/UserInfoEx/init.cpp
@@ -89,29 +89,11 @@ int hLangpack;
  **/
 static INT OnTopToolBarLoaded(WPARAM wParam, LPARAM lParam)
 {
-	UnhookEvent(ghTopToolBarLoaded);
 	DlgAnniversaryListOnTopToolBarLoaded();
 	SvcReminderOnTopToolBarLoaded();
 	return 0;
 }
 
-/**
- * This function is called by the ME_TB_MODULELOADED event.
- * It adds a set of buttons to the Toolbar of the Modern Contact List.
- *
- * @param	wParam	- not used
- * @param	lParam	- not used
- *
- * @return	always 0
- **/
-static INT OnModernToolBarLoaded(WPARAM wParam, LPARAM lParam)
-{
-	UnhookEvent(ghModernToolBarLoaded);
-	DlgAnniversaryListOnToolBarLoaded();
-	SvcReminderOnToolBarLoaded();
-	return 0;
-}
-
 /**
  * This function is called by Miranda just after loading all system modules.
  *
@@ -122,17 +104,13 @@ static INT OnModernToolBarLoaded(WPARAM wParam, LPARAM lParam)
  **/
 static INT OnModulesLoaded(WPARAM wParam, LPARAM lParam)
 {
-	INT_PTR ptr;
-
-	UnhookEvent(ghModulesLoadedHook);
-
 	myGlobals.HaveCListExtraIcons		= ServiceExists(MS_CLIST_EXTRA_SET_ICON);
 	myGlobals.ExtraIconsServiceExist	= ServiceExists(MS_EXTRAICON_REGISTER);
 	myGlobals.PopUpActionsExist			= ServiceExists(MS_POPUP_REGISTERACTIONS);
 	myGlobals.MsgAddIconExist			= ServiceExists(MS_MSG_ADDICON);
 
 	// init meta contacts
-	ptr = CallService(MS_MC_GETPROTOCOLNAME, 0, 0);
+	INT_PTR ptr = CallService(MS_MC_GETPROTOCOLNAME, 0, 0);
 	myGlobals.szMetaProto = (ptr != CALLSERVICE_NOTFOUND) ? (LPCSTR)ptr : NULL;
 
 	// options
@@ -352,10 +330,9 @@ extern "C" INT __declspec(dllexport) Load(void)
 	SvcReminderLoadModule();
 
 	// Now the module is loaded! Start initializing certain things
-	ghModulesLoadedHook		= HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
-	ghTopToolBarLoaded		= HookEvent(ME_TTB_MODULELOADED, OnTopToolBarLoaded);
-	ghModernToolBarLoaded	= HookEvent(ME_TB_MODULELOADED, OnModernToolBarLoaded);
-	ghShutdownHook			= HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown);
+	ghModulesLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+	ghTopToolBarLoaded = HookEvent(ME_TTB_MODULELOADED, OnTopToolBarLoaded);
+	ghShutdownHook = HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown);
 	return 0;
 }
 
diff --git a/plugins/UserInfoEx/svc_reminder.cpp b/plugins/UserInfoEx/svc_reminder.cpp
index deda692bee..132ee62d56 100644
--- a/plugins/UserInfoEx/svc_reminder.cpp
+++ b/plugins/UserInfoEx/svc_reminder.cpp
@@ -901,7 +901,7 @@ static INT OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcw
  *
  * @return	nothing
  **/
-int hTTButton = -1;
+
 VOID SvcReminderOnTopToolBarLoaded()
 {
 	TTBButton ttb = { 0 };
@@ -910,37 +910,9 @@ VOID SvcReminderOnTopToolBarLoaded()
 	ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP | TTBBF_ICONBYHANDLE;
 	ttb.pszService = MS_USERINFO_REMINDER_CHECK;
 	ttb.name = "Check anniversaries";
+	ttb.pszTooltipUp = ttb.pszTooltipDn = LPGEN("Check anniversaries");
 	ttb.hIconHandleDn = ttb.hIconHandleUp = Skin_GetIconHandle(ICO_COMMON_BIRTHDAY);
-				
-	hTTButton = CallService(MS_TTB_ADDBUTTON, (WPARAM) &ttb, 0);
-	if (hTTButton)
-		CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_TIPNAME, hTTButton), (LPARAM)"Check anniversaries");
-}
-
-/**
- * This function is called by the ME_TB_MODULELOADED event.
- * It adds a set of buttons to the Toolbar of the Modern Contact List.
- *
- * @param	none
- *
- * @return	nothing
- **/
-VOID SvcReminderOnToolBarLoaded()
-{
-	TBButton tbb;
-
-	ZeroMemory(&tbb, sizeof(tbb));
-	tbb.cbSize = sizeof(tbb);
-	tbb.defPos = 2000;
-	tbb.tbbFlags = TBBF_VISIBLE | TBBF_SHOWTOOLTIP;
-	tbb.pszButtonName =
-	tbb.pszButtonID = TBB_IDBTN;
-	tbb.pszServiceName = MS_USERINFO_REMINDER_CHECK;
-	tbb.pszTooltipDn =
-	tbb.pszTooltipUp = LPGEN("Check anniversaries");
-	tbb.hPrimaryIconHandle = tbb.hSecondaryIconHandle = Skin_GetIconHandle(ICO_COMMON_BIRTHDAY);
-
-	CallService(MS_TB_ADDBUTTON, 0, (LPARAM) &tbb);
+	TopToolbar_AddButton(&ttb);
 }
 
 
diff --git a/plugins/UserInfoEx/svc_reminder.h b/plugins/UserInfoEx/svc_reminder.h
index f55762be20..210250b9f3 100644
--- a/plugins/UserInfoEx/svc_reminder.h
+++ b/plugins/UserInfoEx/svc_reminder.h
@@ -108,7 +108,6 @@ VOID	SvcReminderCheckAll(const ENotify notify);
 LPCSTR	SvcReminderGetMyBirthdayModule(VOID);
 
 VOID	SvcReminderOnTopToolBarLoaded(VOID);
-VOID	SvcReminderOnToolBarLoaded(VOID);
 VOID	SvcReminderOnModulesLoaded(VOID);
 
 VOID	SvcReminderEnable(BOOLEAN bEnable);
-- 
cgit v1.2.3