summaryrefslogtreecommitdiff
path: root/plugins/Clist_nicer/SRC/CLCButton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Clist_nicer/SRC/CLCButton.cpp')
-rw-r--r--plugins/Clist_nicer/SRC/CLCButton.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/plugins/Clist_nicer/SRC/CLCButton.cpp b/plugins/Clist_nicer/SRC/CLCButton.cpp
index 2af22400ce..2f01b7d3db 100644
--- a/plugins/Clist_nicer/SRC/CLCButton.cpp
+++ b/plugins/Clist_nicer/SRC/CLCButton.cpp
@@ -49,6 +49,20 @@ static BTNS[] =
static int g_index = -1;
+static int getButtonIndex(HANDLE hButton)
+{
+ // nasty clutch. during the initial customization
+ // hButton isn't assigned into BNTS yet
+ if (g_index != -1)
+ return g_index;
+
+ for (int i=0; i < SIZEOF(BTNS); i++)
+ if (BTNS[i].hButton == hButton)
+ return i;
+
+ return -1;
+}
+
static int InitDefaultButtons(WPARAM, LPARAM)
{
for (int i=0; i < SIZEOF(BTNS); i++ ) {
@@ -502,11 +516,12 @@ static void CustomizeToolbar(HANDLE hButton, HWND hWnd, LPARAM)
SetButtonAsCustom(hWnd);
MButtonExtension *bct = (MButtonExtension*) GetWindowLongPtr(hWnd, 0);
- if (g_index != -1) { // adding built-in button
- bct->iCtrlID = BTNS[g_index].ctrlid;
- if (BTNS[g_index].isAction)
+ int idx = getButtonIndex(hButton);
+ if (idx != -1) { // adding built-in button
+ bct->iCtrlID = BTNS[idx].ctrlid;
+ if (BTNS[idx].isAction)
bct->bSendOnDown = TRUE;
- if (!BTNS[g_index].isPush)
+ if (!BTNS[idx].isPush)
bct->bIsPushBtn = TRUE;
}
}