summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/ExternalAPI/m_toptoolbar.h28
-rw-r--r--plugins/TopToolBar/InternalButtons.cpp16
-rw-r--r--plugins/TopToolBar/common.h1
-rw-r--r--plugins/TopToolBar/launchbt.cpp199
-rw-r--r--plugins/TopToolBar/separators.cpp94
-rw-r--r--plugins/TopToolBar/toolbar.cpp340
-rw-r--r--plugins/TopToolBar/ttbopt.cpp25
7 files changed, 207 insertions, 496 deletions
diff --git a/plugins/ExternalAPI/m_toptoolbar.h b/plugins/ExternalAPI/m_toptoolbar.h
index c366c05169..dba10dea61 100644
--- a/plugins/ExternalAPI/m_toptoolbar.h
+++ b/plugins/ExternalAPI/m_toptoolbar.h
@@ -2,24 +2,24 @@
#define M_TOPTOOLBAR_H
//button flags
-#define TTBBF_DISABLED 1
-#define TTBBF_VISIBLE 2
-#define TTBBF_PUSHED 4
-#define TTBBF_SHOWTOOLTIP 8
-#define TTBBF_DRAWBORDER 16
-#define TTBBF_ISSEPARATOR 32
-#define TTBBF_ISLBUTTON 64
-#define TTBBF_ICONBYHANDLE 128
-#define TTBBF_ISSBUTTON 256
+#define TTBBF_DISABLED 0x0001
+#define TTBBF_VISIBLE 0x0002
+#define TTBBF_PUSHED 0x0004
+#define TTBBF_SHOWTOOLTIP 0x0008
+#define TTBBF_ISSEPARATOR 0x0020
+#define TTBBF_ISLBUTTON 0x0040
+#define TTBBF_ICONBYHANDLE 0x0080
+#define TTBBF_ISSBUTTON 0x0100
+#define TTBBF_ASPUSHBUTTON 0x0200
typedef struct {
int cbSize;
- char *pszService;
- DWORD dwFlags;
union {
- LPARAM lParamUp;
+ char *pszService;
TCHAR *program;
};
+ DWORD dwFlags;
+ LPARAM lParamUp;
WPARAM wParamUp;
LPARAM lParamDown;
WPARAM wParamDown;
@@ -72,7 +72,7 @@ lparam = (LPARAM) state
returns: 0 on success, -1 on failure.
*/
#define TTBST_PUSHED 1
-#define TTBST_RELEASED 2
+#define TTBST_RELEASED 2
#define MS_TTB_SETBUTTONSTATE "TopToolBar/SetState"
@@ -92,7 +92,7 @@ lparam = 0,or lparam=lpTTBButton if flag=TTBO_ALLDATA
returns: value on success, -1 on failure.
*/
#define TTBO_FLAGS 0 //get/set all flags
-#define TTBO_POS 1 //position
+#define TTBO_POS 1 //position
#define TTBO_WIDTH 2 //not impemented
#define TTBO_HEIGHT 3 //not impemented
#define TTBO_TIPNAME 4 //tool tip name
diff --git a/plugins/TopToolBar/InternalButtons.cpp b/plugins/TopToolBar/InternalButtons.cpp
index 80d45bb13d..359157e92e 100644
--- a/plugins/TopToolBar/InternalButtons.cpp
+++ b/plugins/TopToolBar/InternalButtons.cpp
@@ -2,7 +2,7 @@
#include "common.h"
#pragma hdrstop
-#define TTBI_GROUPSHOWHIDE "TTBInternal/GroupShowHide"
+#define TTBI_GROUPSHOWHIDE "TTBInternal/GroupShowHide"
#define TTBI_SOUNDSONOFF "TTBInternal/SoundsOnOFF"
#define TTBI_OPTIONSBUTT "TTBInternal/OptionsBUTT"
#define TTBI_MAINMENUBUTT "TTBInternal/MainMenuBUTT"
@@ -66,15 +66,11 @@ int OnSettingChanging(WPARAM wParam, LPARAM lParam)
INT_PTR TTBInternalFindAddButt(WPARAM wParam, LPARAM lParam)
{
CallService("FindAdd/FindAddCommand", 0, 0);
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hFindUsers, TTBST_RELEASED);
return 0;
}
INT_PTR TTBInternalMinimizeButt(WPARAM wParam, LPARAM lParam)
{
- Sleep(30);
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hMinimizeBut, TTBST_RELEASED);
- Sleep(30);
CallService(MS_CLIST_SHOWHIDE, 0, 0);
return 0;
}
@@ -87,16 +83,12 @@ INT_PTR TTBInternalMainMenuButt(WPARAM wParam, LPARAM lParam)
GetCursorPos(&pt);
TrackPopupMenu(hMenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL);
- Sleep(100);
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hMainMenuBut, TTBST_RELEASED);
return 0;
}
INT_PTR TTBInternalOptionsButt(WPARAM wParam, LPARAM lParam)
{
CallService("Options/OptionsCommand", 0, 0);
- Sleep(100);
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hOptionsBut, TTBST_RELEASED);
return 0;
}
@@ -221,7 +213,7 @@ int LoadInternalButtons(HWND hwnd)
ttb.cbSize = sizeof(ttb);
ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_SHOWONLINEUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_SHOWONLINEDN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.dwFlags = (ShowOnline?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
+ ttb.dwFlags = (ShowOnline?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP|TTBBF_ASPUSHBUTTON;
ttb.pszService = MS_CLIST_SETHIDEOFFLINE;
ttb.wParamUp = ttb.wParamDown = -1;
ttb.name = "Show only Online Users";
@@ -229,14 +221,14 @@ int LoadInternalButtons(HWND hwnd)
ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_GROUPSUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_GROUPSDN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.dwFlags = (ShowGroups?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
+ ttb.dwFlags = (ShowGroups?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP|TTBBF_ASPUSHBUTTON;
ttb.pszService = TTBI_GROUPSHOWHIDE;
ttb.name = "Groups On/Off";
hGroupBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_SOUNDUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_SOUNDDN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.dwFlags = (SoundsEnabled?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
+ ttb.dwFlags = (SoundsEnabled?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP|TTBBF_ASPUSHBUTTON;
ttb.pszService = TTBI_SOUNDSONOFF;
ttb.name = "Sounds Enable/Disable";
hSoundsBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h
index d3a55ff3dc..909c981ea9 100644
--- a/plugins/TopToolBar/common.h
+++ b/plugins/TopToolBar/common.h
@@ -53,7 +53,6 @@ int RecreateWindows();
struct TopButtonInt
{
HWND hwnd;
- HWND hwndTip;
int id;
BOOL bPushed;
int dwFlags;
diff --git a/plugins/TopToolBar/launchbt.cpp b/plugins/TopToolBar/launchbt.cpp
deleted file mode 100644
index 3e24b0c2b1..0000000000
--- a/plugins/TopToolBar/launchbt.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-#include "common.h"
-#pragma hdrstop
-
-extern HINSTANCE hInst;
-#define MAXLBUTS 32
-
-LBUTOPT LBUTS[MAXLBUTS];
-static int LButCnt = 0;
-
-extern char *AS(char *str, const char *setting, char *addstr);
-
-//wparam -id
-INT_PTR LaunchService(WPARAM wParam, LPARAM lParam)
-{
- PROCESS_INFORMATION pi;
- STARTUPINFO si = {0};
- si.cb = sizeof(si);
- if ( lParam < 0 || lParam >= MAXLBUTS )
- return -1;
-
- if ( CreateProcess(NULL, LBUTS[lParam].lpath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
- CloseHandle(pi.hProcess);
- CloseHandle(pi.hThread);
- }
- Sleep(20);
- CallService(MS_TTB_SETBUTTONSTATE, LBUTS[lParam].hframe, TTBST_RELEASED);
- return 0;
-}
-
-//wparam -id
-//lparam &LBTOPT
-INT_PTR GetLButton(WPARAM wParam, LPARAM lParam)
-{
- if ( wParam < 0 || wParam >= MAXLBUTS )
- return -1;
-
- LBUTOPT *lbo = ( LBUTOPT* )lParam;
- if (lbo == NULL)
- return -1;
-
- if (LBUTS[wParam].hframe == 0)
- return -1;
-
- *lbo = LBUTS[wParam];
- return 0;
-}
-
-//wparam -id
-//lparam &LBTOPT
-INT_PTR ModifyLButton(WPARAM wParam, LPARAM lParam)
-{
- if ( wParam < 0 || wParam >= LButCnt )
- return -1;
-
- LBUTOPT *lbo = ( LBUTOPT* )lParam;
- if (lbo == NULL)
- return -1;
-
- if (LBUTS[wParam].hframe == 0)
- return -1;
-
- DeleteLBut(wParam, 0);
- if (LBUTS[wParam].lpath != NULL){free(LBUTS[wParam].lpath);}
- if (LBUTS[wParam].name != NULL){free(LBUTS[wParam].name);}
- LBUTS[wParam].name = NULL;
- LBUTS[wParam].lpath = NULL;
-
- if (lbo->name != NULL)
- LBUTS[wParam].name = _strdup(lbo->name);
- if (lbo->lpath != NULL)
- LBUTS[wParam].lpath = _tcsdup(lbo->lpath);
-
- LBUTS[wParam].hframe = InsertLBut(wParam);
- SaveAllLButs();
- return 0;
-}
-
-INT_PTR InsertLBut(int id)
-{
- TTBButton ttb = { 0 };
- ttb.cbSize = sizeof(ttb);
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.dwFlags = TTBBF_VISIBLE|TTBBF_ISLBUTTON;
- ttb.pszServiceDown = TTB_LAUNCHSERVICE;
- ttb.lParamDown = id;
- ttb.name = LBUTS[id].name;
- LButCnt++;
- return TTBAddButton(( WPARAM )&ttb, 0);
-}
-
-INT_PTR DeleteLBut(WPARAM id, LPARAM lParam)
-{
- if (LBUTS[id].hframe != 0) {
- TTBRemoveButton(LBUTS[id].hframe, 0);
- LBUTS[id].hframe = 0;
- if (LBUTS[id].name != NULL){free(LBUTS[id].name);}
- if (LBUTS[id].lpath != NULL){free(LBUTS[id].lpath);}
- LBUTS[id].name = NULL;
- LBUTS[id].lpath = NULL;
-
- LButCnt--;
- }
- return 0;
-}
-
-int LoadAllLButs()
-{
- char buf[255];
- char buf1[10];
- char fixname[255];
- int id;
-
- //must be locked
- memset(buf, 0, SIZEOF(buf));
-
- memset(LBUTS, 0, sizeof(LBUTS));
- for (int i = 0; i < MAXLBUTS; i++) {
- memset(buf1, 0, SIZEOF(buf1));
- _itoa(i, buf1, 10);
- AS(fixname, "LBUT", buf1);
- id = DBGetContactSettingWord(0, TTB_OPTDIR, AS(buf, fixname, ""), -1);
- if (id != -1) {
- LBUTS[i].name = DBGetString(0, TTB_OPTDIR, AS(buf, fixname, "_name"));
- LBUTS[i].lpath = DBGetStringT(0, TTB_OPTDIR, AS(buf, fixname, "_lpath"));
- if (LBUTS[i].lpath == NULL)
- LBUTS[i].lpath = _tcsdup( _T("Execute Path"));
- LBUTS[i].hframe = 0;
- LBUTS[i].hframe = InsertLBut(i);
- }
- }
- return 0;
-}
-
-int SaveAllLButs()
-{
- char buf[255];
- char buf1[10];
- char fixname[255];
-
- //must be locked
- memset(buf, 0, SIZEOF(buf));
-
- for (int i = 0;i<MAXLBUTS;i++) {
- _itoa(i, buf1, 10);
- if (LBUTS[i].hframe != 0) {
- AS(fixname, "LBUT", buf1);
- DBWriteContactSettingWord(0, TTB_OPTDIR, AS(buf, fixname, ""), i);
- DBWriteContactSettingString(0, TTB_OPTDIR, AS(buf, fixname, "_name"), LBUTS[i].name);
- DBWriteContactSettingTString(0, TTB_OPTDIR, AS(buf, fixname, "_lpath"), LBUTS[i].lpath);
- }
- else {
- AS(fixname, "LBUT", buf1);
- DBWriteContactSettingWord(0, TTB_OPTDIR, AS(buf, fixname, ""), -1);
- DBDeleteContactSetting(0, TTB_OPTDIR, AS(buf, fixname, ""));
- DBDeleteContactSetting(0, TTB_OPTDIR, AS(buf, fixname, "_lpath"));
- DBDeleteContactSetting(0, TTB_OPTDIR, AS(buf, fixname, "_name"));
- }
- }
- return 0;
-}
-
-//return 0 on success, -1 on error
-INT_PTR InsertNewFreeLBut(WPARAM wParam, LPARAM lParam)
-{
- char buf[256];
- if (LButCnt < MAXLBUTS) {
- for (int i = 0;i<MAXLBUTS;i++) {
- if (LBUTS[i].hframe == 0) {
- wsprintfA(buf, "%s %d", Translate("Default"), i);
- LBUTS[i].name = _strdup(buf);
- LBUTS[i].lpath = _tcsdup( _T("Execute Path"));
- LBUTS[i].hframe = InsertLBut(i);
- SaveAllLButs();
- return 0;
- }
- }
- }
-
- return -1;
-}
-
-int InitLBut()
-{
- arServices.insert( CreateServiceFunction(TTB_LAUNCHSERVICE, LaunchService));
- arServices.insert( CreateServiceFunction(TTB_ADDLBUTTON, InsertNewFreeLBut));
- arServices.insert( CreateServiceFunction(TTB_REMOVELBUTTON, DeleteLBut));
- arServices.insert( CreateServiceFunction(TTB_MODIFYLBUTTON, ModifyLButton));
- arServices.insert( CreateServiceFunction(TTB_GETLBUTTON, GetLButton));
-
- LoadAllLButs();
- return 0;
-}
-
-int UnInitLBut()
-{
- SaveAllLButs();
- return 0;
-}
diff --git a/plugins/TopToolBar/separators.cpp b/plugins/TopToolBar/separators.cpp
deleted file mode 100644
index f6ef43e8ab..0000000000
--- a/plugins/TopToolBar/separators.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-
-#include "common.h"
-#pragma hdrstop
-
-extern HINSTANCE hInst;
-#define MAXSEPS 32
-int Separators[MAXSEPS];
-
-static int SeparatorCnt = 0;
-
-int InsertSeparator(int id)
-{
- char buf[255];
- wsprintfA(buf, "%s %d", Translate("Separator"), id);
-
- TTBButton ttb = { 0 };
- ttb.cbSize = sizeof(ttb);
- ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR;
- ttb.pszServiceDown = "";
- ttb.pszServiceUp = "";
- ttb.lParamDown = id;
- ttb.name = buf;
- SeparatorCnt++;
- return ( int )TTBAddButton((WPARAM)&ttb, 0);
-}
-
-INT_PTR DeleteSeparator(WPARAM id, LPARAM lParam)
-{
- if ((id<0) || (id >= MAXSEPS)) {
- MessageBoxA(0, "Wrong id", "Error", 0);
- return 0;
- }
-
- if (Separators[id] != 0) {
- TTBRemoveButton(Separators[id], 0);
- Separators[id] = 0;
- SeparatorCnt--;
- }
-
- SaveAllSeparators();
- return 1;
-}
-
-int LoadAllSeparators()
-{
- //must be locked
- char buf[255];
- memset(buf, 0, sizeof(buf));
-
- memset(Separators, 0, sizeof(Separators));
- for (int i = 0; i < MAXSEPS; i++) {
- char buf1[10];
- _itoa(i, buf1, 10);
-
- int id = DBGetContactSettingWord(0, TTB_OPTDIR, AS(buf, "Sep", buf1), -1);
- if (id == i)
- Separators[i] = InsertSeparator(i);
- }
- return 0;
-}
-
-int SaveAllSeparators()
-{
- char buf[255];
- char buf1[10];
-
- for (int i = 0; i < MAXSEPS; i++) {
- memset(buf1, 0, sizeof(buf1));
- _itoa(i, buf1, 10);
- if (Separators[i] != 0)
- DBWriteContactSettingWord(0, TTB_OPTDIR, AS(buf, "Sep", buf1), i);
- else {
- DBWriteContactSettingWord(0, TTB_OPTDIR, AS(buf, "Sep", buf1), -1);
- DBDeleteContactSetting(0, TTB_OPTDIR, AS(buf, "Sep", buf1));
- }
- }
- return 0;
-}
-
-//return 0 on success, -1 on error
-INT_PTR InsertNewFreeSeparator(WPARAM wParam, LPARAM lParam)
-{
- if (SeparatorCnt < MAXSEPS) {
- for (int i = 0; i < MAXSEPS; i++) {
- if (Separators[i] == 0) {
- Separators[i] = InsertSeparator(i);
- SaveAllSeparators();
- return 0;
- }
- }
- }
-
- return -1;
-}
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp
index ab04f4e87b..61374bf316 100644
--- a/plugins/TopToolBar/toolbar.cpp
+++ b/plugins/TopToolBar/toolbar.cpp
@@ -75,7 +75,7 @@ void LoadAllSButs()
int cnt = DBGetContactSettingByte(0, TTB_OPTDIR, "ServiceCnt", 0);
if (cnt > 0)
{
- for (int i = 0; i<cnt; i++)
+ for (int i = 1; i<=cnt; i++)
InsertSBut(i);
}
}
@@ -91,36 +91,17 @@ INT_PTR LaunchService(WPARAM wParam, LPARAM lParam)
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
- Sleep(20);
- CallService(MS_TTB_SETBUTTONSTATE, Buttons[lParam].lParamDown, TTBST_RELEASED);
return 0;
}
-void DeleteLBut(int i)
-{
-// we saving count, tree saving rewriting settings, can have crap in DB but all ok
-/*
- char buf[63];
- char buf1[10];
- char buf2[20];
- _itoa(i, buf1, 10);
- AS(buf2, "Launch", buf1);
-
- DBDeleteContactSetting(0, TTB_OPTDIR, AS(buf, buf2, "_name"));
- DBDeleteContactSetting(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"));
- DBDeleteContactSetting(0, TTB_OPTDIR, AS(buf, buf2, "_Position"));
- DBDeleteContactSetting(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"));
-*/
-}
-
void InsertLBut(int i)
{
TTBButton ttb = { 0 };
ttb.cbSize = sizeof(ttb);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.dwFlags = TTBBF_VISIBLE|TTBBF_ISLBUTTON;
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON;
ttb.pszService = TTB_LAUNCHSERVICE;
ttb.name = LPGEN("Default");
ttb.program = _T("Execute Path");
@@ -133,14 +114,12 @@ void LoadAllLButs()
{
//must be locked
int cnt = DBGetContactSettingByte(0, TTB_OPTDIR, "LaunchCnt", 0);
- for (int i = 0; i<cnt; i++)
+ for (int i = 1; i<=cnt; i++)
InsertLBut(i);
}
//----- Separators -----
-static int SeparatorCnt, LaunchCnt;
-
void InsertSeparator(int i)
{
TTBButton ttb = { 0 };
@@ -151,38 +130,22 @@ void InsertSeparator(int i)
CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_ALLDATA, ttb.lParamDown), (LPARAM)&ttb);
}
-void DeleteSeparator(int i)
-{
-// we saving count, tree saving rewriting settings, can have crap in DB but all ok
-/*
- char buf[63];
- char buf1[10];
- char buf2[20];
- _itoa(i, buf1, 10);
- AS(buf2, "Sep", buf1);
-
- DBDeleteContactSetting(0, TTB_OPTDIR, AS(buf, buf2, "_Position"));
- DBDeleteContactSetting(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"));
-*/
-}
-
void LoadAllSeparators()
{
//must be locked
int cnt = DBGetContactSettingByte(0, TTB_OPTDIR, "SepCnt", 0);
- for (int i = 0; i<cnt; i++)
+ for (int i = 1; i<=cnt; i++)
InsertSeparator(i);
}
-int DBSaveButtonSettings(int butpos)
+int DBSaveButtonSettings(int butpos, int &SepCnt, int &LaunchCnt)
{
char buf[255];
-// memset(buf, 0, SIZEOF(buf));
TopButtonInt& b = Buttons[butpos];
if (b.dwFlags & TTBBF_ISSEPARATOR) {
char buf1[10];
- _itoa(SeparatorCnt++, buf1, 10);
+ _itoa(SepCnt++, buf1, 10);
char buf2[20];
AS(buf2, "Sep", buf1);
@@ -210,10 +173,11 @@ int DBSaveButtonSettings(int butpos)
int SaveAllButtonsOptions()
{
lockbut();
- SeparatorCnt = 0;
- LaunchCnt = 0;
+ int SeparatorCnt = 0;
+ int LaunchCnt = 0;
+
for (int i = 0; i < nButtonsCount; i++)
- DBSaveButtonSettings(i);
+ DBSaveButtonSettings(i,SeparatorCnt,LaunchCnt);
DBWriteContactSettingByte(0, TTB_OPTDIR, "SepCnt", SeparatorCnt);
DBWriteContactSettingByte(0, TTB_OPTDIR, "LaunchCnt", LaunchCnt);
@@ -226,22 +190,25 @@ int DBLoadButtonSettings(int butpos)
char buf[255];
TopButtonInt& b = Buttons[butpos];
BYTE oldv = (b.dwFlags & TTBBF_VISIBLE) != 0;
-
- if (b.dwFlags & TTBBF_ISSEPARATOR) {
- if (b.wParamDown != -1) {
+
+ b.dwFlags = b.dwFlags & (~TTBBF_VISIBLE);
+
+ if (b.dwFlags & TTBBF_ISSEPARATOR)
+ {
+ if (b.wParamDown != 0)
+ {
char buf1[10];
_itoa(b.wParamDown, buf1, 10);
char buf2[20];
AS(buf2, "Sep", buf1);
b.arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), MAX_BUTTONS);
- b.dwFlags = b.dwFlags & (~TTBBF_VISIBLE);
if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 )
b.dwFlags |= TTBBF_VISIBLE;
}
}
else if (b.dwFlags & TTBBF_ISLBUTTON) {
- if (b.wParamDown != -1) {
+ if (b.wParamDown != 0) {
char buf1[10];
_itoa(b.wParamDown, buf1, 10);
char buf2[20];
@@ -249,16 +216,16 @@ int DBLoadButtonSettings(int butpos)
if (b.name != NULL) free(b.name);
b.name = DBGetString(0, TTB_OPTDIR, AS(buf, buf2, "_name"));
+ if (b.program != NULL) free(b.program);
b.program = DBGetStringT(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"));
+
b.arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), MAX_BUTTONS);
- b.dwFlags = b.dwFlags & (~TTBBF_VISIBLE);
if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), oldv) > 0 )
b.dwFlags |= TTBBF_VISIBLE;
}
}
else {
b.arrangedpos = DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, b.name, "_Position"), MAX_BUTTONS);
- b.dwFlags = b.dwFlags & (~TTBBF_VISIBLE);
if ( DBGetContactSettingByte(0, TTB_OPTDIR, AS(buf, b.name, "_Visible"), oldv) > 0 )
b.dwFlags |= TTBBF_VISIBLE;
}
@@ -268,21 +235,20 @@ int DBLoadButtonSettings(int butpos)
int ttbOptionsChanged()
{
//load options
- bkColour = DBGetContactSettingDword(NULL, TTB_OPTDIR, "BkColour", TTBDEFAULT_BKCOLOUR);
+ bkColour = DBGetContactSettingDword(NULL, TTB_OPTDIR, "BkColour", TTBDEFAULT_BKCOLOUR);
if (hBmpBackground) {
DeleteObject(hBmpBackground);
hBmpBackground = NULL;
}
- if ( DBGetContactSettingByte(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) {
+ if (DBGetContactSettingByte(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) {
DBVARIANT dbv;
- if ( !DBGetContactSetting(NULL, TTB_OPTDIR, "BkBitmap", &dbv)) {
- hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal);
- DBFreeVariant(&dbv);
+ if (!DBGetContactSetting(NULL, TTB_OPTDIR, "BkBitmap", &dbv)) {
+ hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
}
- }
-
- backgroundBmpUse = DBGetContactSettingWord(NULL, TTB_OPTDIR, "BkBmpUse", TTBDEFAULT_BKBMPUSE);
+ backgroundBmpUse = DBGetContactSettingWord(NULL, TTB_OPTDIR, "BkBmpUse", TTBDEFAULT_BKBMPUSE);
RECT rc;
GetClientRect(hwndTopToolBar, &rc);
@@ -309,17 +275,23 @@ INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM lParam)
lockbut();
pos = idtopos(wParam);
- if (pos<0 || pos >= nButtonsCount){ulockbut();return -1;}
-
- DestroyWindow(Buttons[pos].hwnd);
- if (Buttons[pos].dwFlags & TTBBF_ISLBUTTON) {
- if (Buttons[pos].name != NULL)
- free(Buttons[pos].name);
- if (Buttons[pos].program != NULL)
- free(Buttons[pos].program);
+ if (pos<0 || pos >= nButtonsCount) {
+ ulockbut();
+ return -1;
}
- else if (Buttons[pos].pszService != NULL)
- free(Buttons[pos].pszService);
+
+ TopButtonInt& b = Buttons[pos];
+
+ DestroyWindow(b.hwnd);
+
+ if (b.name != NULL)
+ free(b.name);
+
+ if ((b.dwFlags & TTBBF_ISLBUTTON) && (b.program != NULL))
+ free(b.program);
+
+ if (b.pszService != NULL)
+ free(b.pszService);
RemoveItemFromList(pos, Buttons, nButtonsCount);
@@ -327,17 +299,6 @@ INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM lParam)
ulockbut();
OptionsPageRebuild();
return 0;
-
-}
-static int UpdateToolTip(int bpos)
-{
- TOOLINFO ti = { 0 };
- ti.cbSize = sizeof(ti);
- ti.lpszText = Buttons[bpos].tooltip;
- ti.hinst = hInst;
- ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS ;
- ti.uId = (UINT_PTR)Buttons[bpos].hwnd;
- return SendMessage(Buttons[bpos].hwndTip, TTM_UPDATETIPTEXT , 0, (LPARAM)&ti);
}
bool nameexists(const char *name)
@@ -379,14 +340,22 @@ HICON LoadIconFromLibrary(char *Name, char *Description, HICON hIcon, HANDLE* ph
int CreateOneWindow(int ButtonPos)
{
- if (!(Buttons[ButtonPos].dwFlags & TTBBF_ISSEPARATOR))
- Buttons[ButtonPos].hwnd = CreateWindow(MIRANDABUTTONCLASS, _T(""), BS_PUSHBUTTON|WS_CHILD|WS_TABSTOP|SS_NOTIFY, 0, 0, BUTTWIDTH, BUTTHEIGHT, hwndTopToolBar, NULL, hInst, 0);
+ TopButtonInt& b = Buttons[ButtonPos];
+
+ if (!(b.dwFlags & TTBBF_ISSEPARATOR))
+ b.hwnd = CreateWindow(MIRANDABUTTONCLASS, _T(""), BS_PUSHBUTTON|WS_CHILD|WS_TABSTOP|SS_NOTIFY, 0, 0, BUTTWIDTH, BUTTHEIGHT, hwndTopToolBar, NULL, hInst, 0);
else
- Buttons[ButtonPos].hwnd = CreateWindow( _T("STATIC"), _T(""), WS_CHILD|SS_NOTIFY, 0, 0, BUTTWIDTH, BUTTHEIGHT, hwndTopToolBar, NULL, hInst, 0);
+ b.hwnd = CreateWindow( _T("STATIC"), _T(""), WS_CHILD|SS_NOTIFY, 0, 0, BUTTWIDTH, BUTTHEIGHT, hwndTopToolBar, NULL, hInst, 0);
+
+ SetWindowLongPtr(b.hwnd, GWLP_USERDATA, b.id);
- SetWindowLongPtr(Buttons[ButtonPos].hwnd, GWLP_USERDATA, Buttons[ButtonPos].id);
if (DBGetContactSettingByte(0, TTB_OPTDIR, "UseFlatButton", 1))
- SendMessage(Buttons[ButtonPos].hwnd, BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(b.hwnd, BUTTONSETASFLATBTN, TRUE, 0);
+
+ if (b.dwFlags & TTBBF_ASPUSHBUTTON)
+ SendMessage(b.hwnd, BUTTONSETASPUSHBTN, 1, 0);
+
+ EnableWindow(b.hwnd,(b.dwFlags & TTBBF_DISABLED)?FALSE:TRUE);
return 0;
}
@@ -417,7 +386,15 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
TopButtonInt& b = Buttons[i];
b.id = nextButtonId++;
- if (but->pszService != NULL) b.pszService = _strdup(but->pszService);
+ if ((but->dwFlags & TTBBF_ISLBUTTON) && (but->program != NULL))
+ b.program = _tcsdup(but->program);
+ else
+ b.program = NULL;
+
+ if (but->pszService != NULL)
+ b.pszService = _strdup(but->pszService);
+ else
+ b.pszService = NULL;
if (but->name != NULL)
b.name = _strdup(but->name);
@@ -441,7 +418,7 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
b.lParamUp = but->lParamUp;
b.wParamDown = but->wParamDown;
b.lParamDown = but->lParamDown;
-
+
b.bPushed = (but->dwFlags & TTBBF_PUSHED) ? TRUE : FALSE;
CreateOneWindow(i);
@@ -452,25 +429,6 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
b.hIconUp = LoadIconFromLibrary(buf, buf, b.hIconUp, &b.hIconHandleUp, NULL);
sprintf(buf, "%s_dn", b.name);
b.hIconDn = LoadIconFromLibrary(buf, buf, b.hIconDn, &b.hIconHandleDn, NULL);
-
- b.hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, NULL,
- WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT,
- hwndTopToolBar, NULL, hInst,
- NULL);
-
- SetWindowPos(b.hwndTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
-
- TOOLINFO ti = { 0 };
- ti.cbSize = sizeof(ti);
- ti.lpszText = _T("");
- ti.hinst = hInst;
- ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS ;
- ti.uId = (UINT_PTR)b.hwnd;
- SendMessage(b.hwndTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
-
- SendMessage(b.hwndTip, TTM_ACTIVATE, (WPARAM)(b.dwFlags&TTBBF_SHOWTOOLTIP)?TRUE:FALSE, 0);
}
SetWindowLongPtr(b.hwnd, GWLP_USERDATA, b.id);
@@ -565,7 +523,6 @@ int ArrangeButtons()
for (i = 0; i < nButtonsCount; i++)
if ( !(Buttons[i].dwFlags & TTBBF_VISIBLE))
ShowWindow(Buttons[i].hwnd, SW_HIDE);
-
RECT winrc;
GetClientRect(hwndTopToolBar, &winrc);
winrc.left = winrc.right-winrc.left;
@@ -621,9 +578,9 @@ int ArrangeButtons()
if (lastxpos+w1+w2+1 > winrc.left) {
lastxpos = 1;
lastypos += BUTTHEIGHT+2;
- CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, hFrameTopWindow), lastypos+BUTTHEIGHT+1);
- newheight = lastypos+BUTTHEIGHT+1;
- }
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, hFrameTopWindow), lastypos+BUTTHEIGHT+1);
+ newheight = lastypos+BUTTHEIGHT+1;
+ }
else {
lastxpos += (isSep(arrangedbuts[i].oldpos)) ? SEPWIDTH+2 : BUTTWIDTH+1;
if ( isSep(arrangedbuts[i+1].oldpos))
@@ -640,19 +597,21 @@ int ArrangeButtons()
int SetButtBitmap(int pos)
{
- int curstyle = GetWindowLongPtr(Buttons[pos].hwnd, GWL_STYLE);
+ TopButtonInt& b = Buttons[pos];
+ int curstyle = GetWindowLongPtr(b.hwnd, GWL_STYLE);
curstyle &= (~SS_BITMAP);
curstyle &= (~SS_ICON);
if (Buttons[pos].dwFlags & TTBBF_ISSEPARATOR) {
- SetWindowLongPtr(Buttons[pos].hwnd, GWL_STYLE, curstyle | SS_BITMAP);
- SendMessage(Buttons[pos].hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmpSeparator);
- SendMessage(Buttons[pos].hwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmpSeparator);
+ SetWindowLongPtr(b.hwnd, GWL_STYLE, curstyle | SS_BITMAP);
+ SendMessage(b.hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmpSeparator);
+ SendMessage(b.hwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmpSeparator);
}
else {
- if (GetWindowLongPtr(Buttons[pos].hwnd, GWL_STYLE) & SS_ICON)
- SetWindowLongPtr(Buttons[pos].hwnd, GWL_STYLE, curstyle | SS_ICON);
- SendMessage(Buttons[pos].hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
+ if (GetWindowLongPtr(b.hwnd, GWL_STYLE) & SS_ICON)
+ SetWindowLongPtr(b.hwnd, GWL_STYLE, curstyle | SS_ICON);
+ SendMessage(b.hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((b.bPushed)?(b.hIconDn):(b.hIconUp)));
+ SendMessage(b.hwnd, BM_SETCHECK, b.bPushed?BST_CHECKED:BST_UNCHECKED ,0);
}
return 0;
@@ -704,10 +663,12 @@ INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam)
return -1;
}
+ TopButtonInt& b = Buttons[pos];
+
switch(LOWORD(wParam)) {
case TTBO_FLAGS:
- retval = Buttons[pos].dwFlags & (!TTBBF_PUSHED);
- if (Buttons[pos].bPushed)
+ retval = b.dwFlags & (!TTBBF_PUSHED);
+ if (b.bPushed)
retval |= TTBBF_PUSHED;
break;
@@ -716,7 +677,7 @@ INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam)
break;
case TTBO_TIPNAME:
- retval = (int)Buttons[pos].tooltip;
+ retval = (int)b.tooltip;
break;
case TTBO_ALLDATA:
@@ -725,18 +686,22 @@ INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam)
if (lpTTB->cbSize != sizeof(TTBButton))
break;
- lpTTB->dwFlags = Buttons[pos].dwFlags & (!TTBBF_PUSHED);
- if (Buttons[pos].bPushed)
+ lpTTB->dwFlags = b.dwFlags & (!TTBBF_PUSHED);
+ if (b.bPushed)
lpTTB->dwFlags |= TTBBF_PUSHED;
- lpTTB->hIconDn=Buttons[pos].hIconDn;
- lpTTB->hIconUp=Buttons[pos].hIconUp;
- lpTTB->lParamUp = Buttons[pos].lParamUp;
- lpTTB->wParamUp = Buttons[pos].wParamUp;
- lpTTB->lParamDown = Buttons[pos].lParamDown;
- lpTTB->wParamDown = Buttons[pos].wParamDown;
+ lpTTB->hIconDn=b.hIconDn;
+ lpTTB->hIconUp=b.hIconUp;
+
+ lpTTB->lParamUp = b.lParamUp;
+ lpTTB->wParamUp = b.wParamUp;
+ lpTTB->lParamDown = b.lParamDown;
+ lpTTB->wParamDown = b.wParamDown;
- lpTTB->pszService = _strdup(Buttons[pos].pszService);
+ if (b.dwFlags & TTBBF_ISLBUTTON)
+ lpTTB->program = _tcsdup(b.program);
+ else
+ lpTTB->pszService = _strdup(b.pszService);
retval = ( INT_PTR )lpTTB;
}
@@ -751,6 +716,36 @@ INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam)
return retval;
}
+#define BitChanged(c) (b.dwFlags ^ Flags) & c
+
+DWORD CheckFlags(TopButtonInt& b, DWORD Flags)
+{
+ int res = 0;
+ if (BitChanged(TTBBF_DISABLED)) {
+ b.dwFlags^=TTBBF_DISABLED;
+ EnableWindow(b.hwnd,(b.dwFlags & TTBBF_DISABLED)?FALSE:TRUE);
+ }
+ if (BitChanged(TTBBF_ASPUSHBUTTON)) {
+ b.dwFlags^=TTBBF_ASPUSHBUTTON;
+ SendMessage(b.hwnd, BUTTONSETASPUSHBTN, (b.dwFlags & TTBBF_ASPUSHBUTTON)?1:0, 0);
+ }
+ if (BitChanged(TTBBF_SHOWTOOLTIP)) {
+ b.dwFlags^=TTBBF_SHOWTOOLTIP;
+ SendMessage(b.hwnd,BUTTONADDTOOLTIP,
+ (WPARAM)((b.dwFlags & TTBBF_SHOWTOOLTIP)?b.tooltip:L""),BATF_UNICODE);
+ }
+ // next settings changing visual side, requires additional actions
+ if (BitChanged(TTBBF_VISIBLE)) {
+ b.dwFlags^=TTBBF_VISIBLE;
+ res|=TTBBF_VISIBLE;
+ }
+ if (BitChanged(TTBBF_PUSHED)) {
+ b.dwFlags^=TTBBF_PUSHED;
+ res|=TTBBF_PUSHED;
+ b.bPushed = (b.dwFlags & TTBBF_PUSHED) ? TRUE : FALSE;
+ }
+ return res;
+}
INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam)
{
@@ -760,16 +755,20 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam)
pos = idtopos(HIWORD(wParam));
if (pos<0 || pos >= nButtonsCount){ulockbut();return -1;}
+ TopButtonInt& b = Buttons[pos];
+
switch(LOWORD(wParam)) {
case TTBO_FLAGS:
- if (Buttons[pos].dwFlags == lParam)
+ if (b.dwFlags == lParam)
break;
- Buttons[pos].dwFlags = lParam;
- Buttons[pos].bPushed = (Buttons[pos].dwFlags & TTBBF_PUSHED) ? TRUE : FALSE;
-
- SetButtBitmap(pos);
- SendMessage(Buttons[pos].hwndTip, TTM_ACTIVATE, (WPARAM)(Buttons[pos].dwFlags & TTBBF_SHOWTOOLTIP) ? TRUE : FALSE, 0);
+ retval = CheckFlags(b,lParam);
+
+ if (retval & TTBBF_PUSHED)
+ SetButtBitmap(pos);
+ if (retval & TTBBF_VISIBLE)
+ ArrangeButtons();
+
retval = 1;
break;
@@ -788,10 +787,10 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam)
if (lParam == 0)
break;
- if (Buttons[pos].tooltip != NULL)
- free(Buttons[pos].tooltip);
- Buttons[pos].tooltip = _tcsdup( TranslateTS( _A2T((LPCSTR)lParam)));
- UpdateToolTip(pos);
+ if (b.tooltip != NULL)
+ free(b.tooltip);
+ b.tooltip = _tcsdup( TranslateTS( _A2T((LPCSTR)lParam)));
+ SendMessage(b.hwnd,BUTTONADDTOOLTIP,(WPARAM)b.tooltip,BATF_UNICODE);
retval = 1;
break;
@@ -801,21 +800,28 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam)
if (lpTTB->cbSize != sizeof(TTBButton))
break;
- Buttons[pos].dwFlags = lpTTB->dwFlags;
- Buttons[pos].hIconUp = lpTTB->hIconUp;
- Buttons[pos].hIconDn = lpTTB->hIconDn;
- Buttons[pos].lParamUp = lpTTB->lParamUp;
- Buttons[pos].wParamUp = lpTTB->wParamUp;
- Buttons[pos].lParamDown = lpTTB->lParamDown;
- Buttons[pos].wParamDown = lpTTB->wParamDown;
+ retval = CheckFlags(b,lpTTB->dwFlags);
- if (Buttons[pos].pszService != NULL)
- free(Buttons[pos].pszService);
+ b.hIconUp = lpTTB->hIconUp;
+ b.hIconDn = lpTTB->hIconDn;
- Buttons[pos].pszService = _strdup(lpTTB->pszService);
+ if (b.dwFlags & TTBBF_ISLBUTTON) {
+ if (b.program != NULL)
+ free(b.program);
+ b.program = _tcsdup(lpTTB->program);
+ }
+ else {
+ if (b.pszService != NULL)
+ free(b.pszService);
+ b.pszService = _strdup(lpTTB->pszService);
+ }
+
+ b.lParamUp = lpTTB->lParamUp;
+ b.wParamUp = lpTTB->wParamUp;
+ b.lParamDown = lpTTB->lParamDown;
+ b.wParamDown = lpTTB->wParamDown;
- Buttons[pos].bPushed = (Buttons[pos].dwFlags&TTBBF_PUSHED)?TRUE:FALSE;
- SendMessage(Buttons[pos].hwndTip, TTM_ACTIVATE, (WPARAM)(Buttons[pos].dwFlags&TTBBF_SHOWTOOLTIP)?TRUE:FALSE, 0);
+ SetButtBitmap(pos); //!! Need to check, requires it or not
ArrangeButtons();
retval = 1;
}
@@ -976,21 +982,27 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
return 0;
}
- if (Buttons[pos].bPushed) {
+ TopButtonInt& b = Buttons[pos];
+
+ b.bPushed = !b.bPushed;
+ SetButtBitmap(pos);
+ if (!b.bPushed) {
//Dn -> Up
- Buttons[pos].bPushed = !Buttons[pos].bPushed;
- SetButtBitmap(pos);
- if (Buttons[pos].pszService != NULL)
- CallService(Buttons[pos].pszService, Buttons[pos].wParamUp, Buttons[pos].lParamUp);
+ if (!(b.dwFlags & TTBBF_ISLBUTTON)) // must be always true
+ if (b.pszService != NULL)
+ CallService(b.pszService, b.wParamUp, b.lParamUp);
}
else {
//Up -> Dn
- Buttons[pos].bPushed = !Buttons[pos].bPushed;
- SetButtBitmap(pos);
- if (Buttons[pos].pszService != NULL)
- CallService(Buttons[pos].pszService, Buttons[pos].wParamDown, Buttons[pos].lParamDown);
+/*
+ if (b.dwFlags & TTBBF_ISLBUTTON) {
+ if (b.program != NULL)
+ LaunchService(0,pos);
+ }
+ else*/ if (b.pszService != NULL)
+ CallService(b.pszService, b.wParamDown, b.lParamDown);
}
ulockbut();
@@ -1119,10 +1131,10 @@ int LoadToolbarModule()
arServices.insert( CreateServiceFunction(MS_TTB_GETBUTTONOPTIONS, TTBGetOptions));
arServices.insert( CreateServiceFunction(MS_TTB_SETBUTTONOPTIONS, TTBSetOptions));
-
- arServices.insert( CreateServiceFunction("TTB_ONSTARTUPFIRE", OnEventFire));
arServices.insert( CreateServiceFunction(TTB_LAUNCHSERVICE, LaunchService));
+
+ arServices.insert( CreateServiceFunction("TTB_ONSTARTUPFIRE", OnEventFire));
BUTTHEIGHT = DBGetContactSettingByte(0, TTB_OPTDIR, "BUTTHEIGHT", 16);
BUTTWIDTH = DBGetContactSettingByte(0, TTB_OPTDIR, "BUTTWIDTH", 20);
diff --git a/plugins/TopToolBar/ttbopt.cpp b/plugins/TopToolBar/ttbopt.cpp
index 4d6ab5916d..88e2124e36 100644
--- a/plugins/TopToolBar/ttbopt.cpp
+++ b/plugins/TopToolBar/ttbopt.cpp
@@ -181,15 +181,15 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
GetDlgItemText(hwndDlg, IDC_EPATH, buf, 255);
btn->program = _tcsdup(buf);
- tvi.mask = TVIF_TEXT;
- tvi.pszText = mir_a2t( btn->name );
- TreeView_SetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
+ tvi.mask = TVIF_TEXT;
+ tvi.pszText = mir_a2t( btn->name );
+ TreeView_SetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
}
break;
}
if (ctrlid == IDC_ADDLBUTTON) {
- InsertLBut(-1);
+ InsertLBut(0);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
@@ -197,7 +197,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
//----- Separators -----
if (ctrlid == IDC_ADDSEP) {
- InsertSeparator(-1);
+ InsertSeparator(0);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
@@ -212,14 +212,10 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
TreeView_GetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
btn = (TopButtonInt*)tvi.lParam;
- if (btn->dwFlags & TTBBF_ISSEPARATOR) {
- DeleteSeparator(btn->wParamDown);
+ // if button enabled for separator and launch only, no need condition
+ // except possible service button introducing
+ if (btn->dwFlags & (TTBBF_ISSEPARATOR | TTBBF_ISLBUTTON))
TTBRemoveButton(btn->lParamDown, 0);
- }
- else if (btn->dwFlags & TTBBF_ISLBUTTON) {
- DeleteLBut(btn->wParamDown);
- TTBRemoveButton(btn->lParamDown, 0);
- }
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -283,8 +279,13 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), TRUE);
if (btn->name != NULL)
SetDlgItemTextA(hwndDlg, IDC_ENAME, btn->name);
+ else
+ SetDlgItemTextA(hwndDlg, IDC_ENAME, "");
+
if (btn->program != NULL)
SetDlgItemText(hwndDlg, IDC_EPATH, btn->program);
+ else
+ SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
}
else
{