summaryrefslogtreecommitdiff
path: root/plugins/StatusPlugins/StartupStatus/toolbars.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-13 08:49:45 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-13 08:49:45 +0000
commit9a7e2f9fd248e17ffc5c2a8d9581172507ad8803 (patch)
treefa790697697405a6dbba00e72ff3d57f4db2a01a /plugins/StatusPlugins/StartupStatus/toolbars.cpp
parent8f1e41b61140fdca624f2e8b25644d730502300f (diff)
fix for TTB button in StartupStatus options
git-svn-id: http://svn.miranda-ng.org/main/trunk@941 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/StatusPlugins/StartupStatus/toolbars.cpp')
-rw-r--r--plugins/StatusPlugins/StartupStatus/toolbars.cpp43
1 files changed, 9 insertions, 34 deletions
diff --git a/plugins/StatusPlugins/StartupStatus/toolbars.cpp b/plugins/StatusPlugins/StartupStatus/toolbars.cpp
index a7a13a6bc9..982716723d 100644
--- a/plugins/StatusPlugins/StartupStatus/toolbars.cpp
+++ b/plugins/StatusPlugins/StartupStatus/toolbars.cpp
@@ -27,34 +27,20 @@
static HANDLE hTtbDown = 0, hTtbUp = 0;
-static HANDLE* ttbButtons = NULL;
-static int ttbButtonCount = 0;
+static LIST<void> ttbButtons(1);
/////////////////////////////////////////////////////////////////////////////////////////
-int RemoveTopToolbarButtons()
+void RemoveTopToolbarButtons()
{
- int profileCount, orgButtonCount;
-
- profileCount = CallService(MS_SS_GETPROFILECOUNT, 0, 0);
- orgButtonCount = ttbButtonCount;
- for (int i=0; i < orgButtonCount; i++)
- if (CallService(MS_TTB_REMOVEBUTTON, (WPARAM)ttbButtons[i], 0) != 1)
- ttbButtonCount -= 1;
-
- if (ttbButtonCount == 0) {
- free(ttbButtons);
- ttbButtons = NULL;
- }
- else ttbButtons = ( HANDLE* )realloc(ttbButtons, profileCount*sizeof(HANDLE));
-
- return 0;
+ for (int i=ttbButtons.getCount()-1; i >= 0; i--)
+ CallService(MS_TTB_REMOVEBUTTON, (WPARAM)ttbButtons[i], 0);
+ ttbButtons.destroy();
}
int CreateTopToolbarButtons(WPARAM wParam, LPARAM lParam)
{
int profileCount = CallService(MS_SS_GETPROFILECOUNT, 0, 0);
- ttbButtons = ( HANDLE* )realloc(ttbButtons, profileCount*sizeof(HANDLE));
TTBButton ttb = { 0 };
ttb.cbSize = sizeof(ttb);
@@ -71,26 +57,15 @@ int CreateTopToolbarButtons(WPARAM wParam, LPARAM lParam)
if (DBGetContactSetting(NULL, MODULENAME, setting, &dbv))
continue;
- char profileName[128];
- strncpy(profileName, dbv.pszVal, sizeof(profileName)-1);
ttb.hIconHandleDn = hTtbDown;
ttb.hIconHandleUp = hTtbUp;
ttb.wParamDown = ttb.wParamUp = i;
- ttb.name = ttb.pszTooltipUp = LPGEN(profileName);
+ ttb.name = ttb.pszTooltipUp = dbv.pszVal;
HANDLE ttbAddResult = TopToolbar_AddButton(&ttb);
- if (ttbAddResult) {
- ttbButtons[ttbButtonCount] = ttbAddResult;
- DBFreeVariant(&dbv);
- ttbButtonCount += 1;
- }
+ if (ttbAddResult)
+ ttbButtons.insert(ttbAddResult);
+ DBFreeVariant(&dbv);
}
- if (ttbButtonCount > 0)
- ttbButtons = ( HANDLE* )realloc(ttbButtons, ttbButtonCount*sizeof(HANDLE));
- else {
- free(ttbButtons);
- ttbButtons = NULL;
- }
-
return 0;
}