summaryrefslogtreecommitdiff
path: root/plugins/TopToolBar
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-11 21:12:00 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-11 21:12:00 +0000
commit2bbcdb330bbf4d3bbd636f7014ee447c9be95495 (patch)
tree7b1deacf6b281d03bcfdfdf671fe4b9d0498a0d2 /plugins/TopToolBar
parentc67de31a8ce0b1a43b11662674ac0b64d14812d4 (diff)
fix for a TTB to remove buttons of the dynamically unloaded plugins
git-svn-id: http://svn.miranda-ng.org/main/trunk@911 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TopToolBar')
-rw-r--r--plugins/TopToolBar/main.rc2
-rw-r--r--plugins/TopToolBar/toolbar.cpp31
-rw-r--r--plugins/TopToolBar/topbutton.cpp3
3 files changed, 33 insertions, 3 deletions
diff --git a/plugins/TopToolBar/main.rc b/plugins/TopToolBar/main.rc
index 3f795295fa..f6efd9369b 100644
--- a/plugins/TopToolBar/main.rc
+++ b/plugins/TopToolBar/main.rc
@@ -36,7 +36,7 @@ BEGIN
LTEXT "Button width",IDC_STATIC,169,150,100,8
EDITTEXT IDC_BUTTWIDTH,272,148,27,12,ES_NUMBER
CONTROL "",IDC_SPIN_WIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,289,148,8,12
- LTEXT "Inteval between buttons",IDC_STATIC,169,166,100,8
+ LTEXT "Interval between buttons",IDC_STATIC,169,166,100,8
EDITTEXT IDC_BUTTGAP,272,164,27,12,ES_NUMBER
CONTROL "",IDC_SPIN_GAP,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,289,164,8,12
CONTROL "Use flat mode",IDC_USEFLAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,185,130,10
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp
index a41c43607f..ac81128d50 100644
--- a/plugins/TopToolBar/toolbar.cpp
+++ b/plugins/TopToolBar/toolbar.cpp
@@ -267,6 +267,7 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
return -1;
b = CreateButton(but);
+ b->hLangpack = (int)lParam;
b->LoadSettings();
Buttons.insert(b);
b->CreateWnd();
@@ -550,6 +551,31 @@ static INT_PTR TTBSetCustomProc(WPARAM wParam, LPARAM lParam)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// Removes buttons of plugins being unloads. lParam = HINSTANCE
+
+int OnPluginUnload(WPARAM wParam, LPARAM lParam)
+{
+ int hLangpack = CallService(MS_LANGPACK_LOOKUPHANDLE, 0, lParam);
+ if (hLangpack) {
+ bool bNeedUpdate = false;
+ mir_cslock lck(csButtonsHook);
+
+ for (int i=Buttons.getCount()-1; i >= 0; i--)
+ if (Buttons[i]->hLangpack == hLangpack) {
+ TTBRemoveButton(Buttons[i]->id, 0);
+ bNeedUpdate = true;
+ }
+
+ if (bNeedUpdate) {
+ ArrangeButtons();
+ if (g_ctrl->hWnd)
+ PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, TRUE, 0);
+ }
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
int OnModulesLoad(WPARAM wParam, LPARAM lParam)
{
@@ -605,6 +631,7 @@ int LoadToolbarModule()
InitializeCriticalSection(&csButtonsHook);
hBmpSeparator = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_SEP));
+ HookEvent(ME_SYSTEM_MODULEUNLOAD, OnPluginUnload);
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoad);
HookEvent(ME_SKIN2_ICONSCHANGED, OnIconChange);
HookEvent(ME_OPT_INITIALISE, TTBOptInit);
@@ -618,12 +645,12 @@ int LoadToolbarModule()
CreateServiceFunction(MS_TTB_SETBUTTONSTATE, TTBSetState);
CreateServiceFunction(MS_TTB_GETBUTTONSTATE, TTBGetState);
-
+
CreateServiceFunction(MS_TTB_GETBUTTONOPTIONS, TTBGetOptions);
CreateServiceFunction(MS_TTB_SETBUTTONOPTIONS, TTBSetOptions);
CreateServiceFunction(TTB_LAUNCHSERVICE, LaunchService);
-
+
CreateServiceFunction("TopToolBar/SetCustomProc", TTBSetCustomProc);
CreateServiceFunction("TTB_ONSTARTUPFIRE", OnEventFire);
diff --git a/plugins/TopToolBar/topbutton.cpp b/plugins/TopToolBar/topbutton.cpp
index 762b784934..34a6c4d5df 100644
--- a/plugins/TopToolBar/topbutton.cpp
+++ b/plugins/TopToolBar/topbutton.cpp
@@ -7,6 +7,9 @@ static int maxid = 10000;
TopButtonInt::~TopButtonInt()
{
+ if (hwnd)
+ DestroyWindow(hwnd);
+
if (dwFlags & TTBBF_ISLBUTTON) {
mir_free(ptszProgram);
}