From 6ac63284a8f93f977db66673727d4995a86764c4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 10 Mar 2013 12:45:32 +0000 Subject: various TTB initialization issues git-svn-id: http://svn.miranda-ng.org/main/trunk@3957 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AutoShutdown/src/common.h | 2 ++ plugins/AutoShutdown/src/main.cpp | 7 ++----- plugins/AutoShutdown/src/settingsdlg.cpp | 31 ++++++++++--------------------- 3 files changed, 14 insertions(+), 26 deletions(-) (limited to 'plugins/AutoShutdown') diff --git a/plugins/AutoShutdown/src/common.h b/plugins/AutoShutdown/src/common.h index 1fb595186d..4c117f02ee 100644 --- a/plugins/AutoShutdown/src/common.h +++ b/plugins/AutoShutdown/src/common.h @@ -72,3 +72,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "watcher.h" #include "resource.h" #include "version.h" + +extern IconItem iconList[]; \ No newline at end of file diff --git a/plugins/AutoShutdown/src/main.cpp b/plugins/AutoShutdown/src/main.cpp index b65d990d7a..da5450c630 100644 --- a/plugins/AutoShutdown/src/main.cpp +++ b/plugins/AutoShutdown/src/main.cpp @@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "common.h" HINSTANCE hInst; -static HANDLE hHookModulesLoaded; int hLangpack; PLUGININFOEX pluginInfo = { @@ -53,7 +52,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, VOID *pReserved) static int ShutdownModulesLoaded(WPARAM wParam,LPARAM lParam) { - if(ServiceExists("DBEditorpp/RegisterSingleModule")) + if ( ServiceExists("DBEditorpp/RegisterSingleModule")) CallService("DBEditorpp/RegisterSingleModule",(WPARAM)"AutoShutdown",0); return 0; @@ -82,14 +81,12 @@ extern "C" __declspec(dllexport) int Load(void) InitSettingsDlg(); InitOptions(); - hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ShutdownModulesLoaded); + HookEvent(ME_SYSTEM_MODULESLOADED, ShutdownModulesLoaded); return 0; } extern "C" __declspec(dllexport) int Unload(void) { - UnhookEvent(hHookModulesLoaded); - UninitOptions(); UninitSettingsDlg(); /* before UninitWatcher() */ UninitWatcher(); /* before UninitFrame() */ diff --git a/plugins/AutoShutdown/src/settingsdlg.cpp b/plugins/AutoShutdown/src/settingsdlg.cpp index f528822c31..84fa86b5e4 100644 --- a/plugins/AutoShutdown/src/settingsdlg.cpp +++ b/plugins/AutoShutdown/src/settingsdlg.cpp @@ -23,8 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* Menu Item */ static HANDLE hServiceMenuCommand; -/* Toolbar Button */ -static HANDLE hHookToolbarLoaded; /* Services */ static HANDLE hServiceShowDlg; static HWND hwndSettingsDlg; @@ -407,20 +405,15 @@ static HANDLE hToolbarButton; static int ToolbarLoaded(WPARAM wParam,LPARAM lParam) { - TTBButton ttbb = {0}; - ttbb.cbSize = sizeof(ttbb); - /* toptoolbar offers icolib support */ - ttbb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ACTIVE), IMAGE_ICON, 0, 0, 0); - ttbb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_INACTIVE), IMAGE_ICON, 0, 0, 0); - ttbb.pszService = "AutoShutdown/MenuCommand"; - ttbb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; - ttbb.name = LPGEN("Start/Stop automatic shutdown"); - ttbb.pszTooltipUp = LPGEN("Stop automatic shutdown"); - ttbb.pszTooltipDn = LPGEN("Start automatic shutdown"); - - hToolbarButton = TopToolbar_AddButton(&ttbb); - if(ttbb.hIconUp != NULL) DestroyIcon(ttbb.hIconUp); - if(ttbb.hIconDn != NULL) DestroyIcon(ttbb.hIconDn); + TTBButton ttb = { sizeof(ttb) }; + ttb.hIconHandleUp = iconList[1].hIcolib; + ttb.hIconHandleDn = iconList[2].hIcolib; + ttb.pszService = "AutoShutdown/MenuCommand"; + ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; + ttb.name = LPGEN("Start/Stop automatic shutdown"); + ttb.pszTooltipUp = LPGEN("Stop automatic shutdown"); + ttb.pszTooltipDn = LPGEN("Start automatic shutdown"); + hToolbarButton = TopToolbar_AddButton(&ttb); return 0; } @@ -435,7 +428,6 @@ void SetShutdownToolbarButton(BOOL fActive) /************************* Menu Item **********************************/ static HANDLE hMainMenuItem,hTrayMenuItem; -extern IconItem iconList[]; void SetShutdownMenuItem(BOOL fActive) { @@ -482,8 +474,7 @@ void InitSettingsDlg(void) hMainMenuItem=hTrayMenuItem=NULL; SetShutdownMenuItem(FALSE); /* Toolbar Item */ - hToolbarButton=0; - hHookToolbarLoaded=HookEvent(ME_TTB_MODULELOADED,ToolbarLoaded); /* no service to check for */ + HookEvent(ME_TTB_MODULELOADED,ToolbarLoaded); /* no service to check for */ /* Hotkey */ AddHotkey(); /* Services */ @@ -493,8 +484,6 @@ void InitSettingsDlg(void) void UninitSettingsDlg(void) { - /* Toolbar Item */ - UnhookEvent(hHookToolbarLoaded); /* Menu Item */ DestroyServiceFunction(hServiceMenuCommand); /* Services */ -- cgit v1.2.3