summaryrefslogtreecommitdiff
path: root/plugins/TopToolBar
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/TopToolBar')
-rw-r--r--plugins/TopToolBar/InternalButtons.cpp14
-rw-r--r--plugins/TopToolBar/TopToolBar.vcxproj2
-rw-r--r--plugins/TopToolBar/TopToolBar.vcxproj.filters6
-rw-r--r--plugins/TopToolBar/common.h45
-rw-r--r--plugins/TopToolBar/main.cpp1
-rw-r--r--plugins/TopToolBar/main.rc10
-rw-r--r--plugins/TopToolBar/resource.h2
-rw-r--r--plugins/TopToolBar/toolbar.cpp343
-rw-r--r--plugins/TopToolBar/ttbopt.cpp154
9 files changed, 349 insertions, 228 deletions
diff --git a/plugins/TopToolBar/InternalButtons.cpp b/plugins/TopToolBar/InternalButtons.cpp
index 1d1d357c76..80d45bb13d 100644
--- a/plugins/TopToolBar/InternalButtons.cpp
+++ b/plugins/TopToolBar/InternalButtons.cpp
@@ -222,7 +222,7 @@ int LoadInternalButtons(HWND hwnd)
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.pszServiceDown = ttb.pszServiceUp = MS_CLIST_SETHIDEOFFLINE;
+ ttb.pszService = MS_CLIST_SETHIDEOFFLINE;
ttb.wParamUp = ttb.wParamDown = -1;
ttb.name = "Show only Online Users";
hOnlineBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
@@ -230,42 +230,42 @@ 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.pszServiceDown = ttb.pszServiceUp = TTBI_GROUPSHOWHIDE;
+ 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.pszServiceDown = ttb.pszServiceUp = TTBI_SOUNDSONOFF;
+ ttb.pszService = TTBI_SOUNDSONOFF;
ttb.name = "Sounds Enable/Disable";
hSoundsBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_OPTIONSUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_OPTIONSDN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
- ttb.pszServiceDown = ttb.pszServiceUp = TTBI_OPTIONSBUTT;
+ ttb.pszService = TTBI_OPTIONSBUTT;
ttb.name = "Show Options Page";
hOptionsBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MINIMIZEUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MINIMIZEDN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE;
- ttb.pszServiceDown = ttb.pszServiceUp = TTBI_MINIMIZEBUTT;
+ ttb.pszService = TTBI_MINIMIZEBUTT;
ttb.name = "Minimize Button";
hMinimizeBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_FINDADDUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_FINDADDDN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE;
- ttb.pszServiceDown = ttb.pszServiceUp = TTBI_FINDADDBUTT;
+ ttb.pszService = TTBI_FINDADDBUTT;
ttb.name = "Find/Add Contacts";
hFindUsers = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MIRANDAUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MIRANDADN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
- ttb.pszServiceDown = ttb.pszServiceUp = TTBI_MAINMENUBUTT;
+ ttb.pszService = TTBI_MAINMENUBUTT;
ttb.name = "Show Main Menu";
hMainMenuBut = (HANDLE)TTBAddButton((WPARAM)&ttb, 0);
diff --git a/plugins/TopToolBar/TopToolBar.vcxproj b/plugins/TopToolBar/TopToolBar.vcxproj
index 2a86528e9e..788b21a647 100644
--- a/plugins/TopToolBar/TopToolBar.vcxproj
+++ b/plugins/TopToolBar/TopToolBar.vcxproj
@@ -268,11 +268,9 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="InternalButtons.cpp" />
- <ClCompile Include="launchbt.cpp" />
<ClCompile Include="main.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
- <ClCompile Include="separators.cpp" />
<ClCompile Include="toolbar.cpp" />
<ClCompile Include="ttbopt.cpp" />
</ItemGroup>
diff --git a/plugins/TopToolBar/TopToolBar.vcxproj.filters b/plugins/TopToolBar/TopToolBar.vcxproj.filters
index fc8f42824a..7885e6202c 100644
--- a/plugins/TopToolBar/TopToolBar.vcxproj.filters
+++ b/plugins/TopToolBar/TopToolBar.vcxproj.filters
@@ -93,12 +93,6 @@
<ClCompile Include="InternalButtons.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="launchbt.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="separators.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="ttbopt.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h
index 52658e5b9a..d3a55ff3dc 100644
--- a/plugins/TopToolBar/common.h
+++ b/plugins/TopToolBar/common.h
@@ -61,7 +61,8 @@ struct TopButtonInt
HICON hIconUp, hIconDn;
HANDLE hIconHandleUp, hIconHandleDn;
- char *pszServiceUp, *pszServiceDown;
+ char *pszService;
+ TCHAR *program;
char *name;
TCHAR *tooltip;
@@ -94,12 +95,6 @@ int OptionsPageRebuild();
void lockbut();
void ulockbut();
-//return - 0 success, -1 on error
-#define TTB_ADDSEPARATOR "TTB/AddSeparator"
-//wparam sepid
-#define TTB_REMOVESEPARATOR "TTB/RemoveSeparator"
-
-
//append string
char *AS(char *str, const char *setting, char *addstr)
{
@@ -111,17 +106,6 @@ char *AS(char *str, const char *setting, char *addstr)
}
#define TTB_LAUNCHSERVICE "TTB/LaunchSerice"
-//wparam -id
-//lparam &LBTOPT
-#define TTB_MODIFYLBUTTON "TTB/ModifyLButton"
-
-//wparam -id
-//lparam &LBTOPT
-#define TTB_GETLBUTTON "TTB/GetLButton"
-
-#define TTB_ADDLBUTTON "TTB/AddLButton"
-#define TTB_REMOVELBUTTON "TTB/RemoveLButton"
-#define MYMIRANDABUTTONCLASS _T("MButtonClass") //_T("MyMIRANDABUTTONCLASS")
int LoadInternalButtons( HWND );
int UnLoadInternalButtons( void );
@@ -129,37 +113,22 @@ int UnLoadInternalButtons( void );
int LoadToolbarModule( void );
int UnloadToolbarModule( void );
-int LoadAllSeparators( void );
-
int SetAllBitmaps( void );
int SaveAllLButs( void );
int SaveAllButtonsOptions( void );
-int SaveAllSeparators( void );
-
-int InitLBut();
-int UnInitLBut();
void lockbut();
void ulockbut();
INT_PTR TTBAddButton(WPARAM, LPARAM);
INT_PTR TTBRemoveButton(WPARAM, LPARAM);
-INT_PTR DeleteLBut(WPARAM, LPARAM);
-INT_PTR ModifyLButton(WPARAM, LPARAM);
-INT_PTR GetLButton(WPARAM, LPARAM);
-INT_PTR InsertNewFreeSeparator(WPARAM, LPARAM);
-INT_PTR DeleteSeparator(WPARAM, LPARAM);
-int OnModulesLoad(WPARAM, LPARAM);
-
-INT_PTR InsertLBut(int id);
+void InsertSeparator( int i );
+void DeleteSeparator(int i);
+void DeleteLBut(int i);
+void InsertLBut(int i);
-struct LBUTOPT
-{
- int hframe;
- TCHAR *lpath;
- char *name;
-};
+int OnModulesLoad(WPARAM, LPARAM);
#define BM_SETPRIVATEICON (WM_USER + 6)
#define BM_SETIMLICON (WM_USER + 7)
diff --git a/plugins/TopToolBar/main.cpp b/plugins/TopToolBar/main.cpp
index 7fd001a4fb..6874e43ce8 100644
--- a/plugins/TopToolBar/main.cpp
+++ b/plugins/TopToolBar/main.cpp
@@ -61,7 +61,6 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
extern "C" int __declspec(dllexport) Unload(void)
{
- UnInitLBut();
UnLoadInternalButtons();
UnloadToolbarModule();
diff --git a/plugins/TopToolBar/main.rc b/plugins/TopToolBar/main.rc
index 3427ac369b..944f35c4e7 100644
--- a/plugins/TopToolBar/main.rc
+++ b/plugins/TopToolBar/main.rc
@@ -31,17 +31,17 @@ BEGIN
GROUPBOX "Buttons Order && Visibility",IDC_STATIC,10,0,150,180
CONTROL "Tree1",IDC_BUTTONORDERTREE,"SysTreeView32",TVS_NOTOOLTIPS | TVS_CHECKBOXES | WS_BORDER | WS_HSCROLL | WS_TABSTOP,18,25,134,148
LTEXT "Buttons order:",IDC_STATIC,18,15,132,8
+
PUSHBUTTON "Add Separator",IDC_ADDSEP,175,15,55,14
- PUSHBUTTON "Del Separator",IDC_REMOVESEP,235,15,55,14
- PUSHBUTTON "Add Launch",IDC_ADDLBUTTON,180,60,100,14
- PUSHBUTTON "Del Launch",IDC_DELLBUTTON,180,81,100,14
+ PUSHBUTTON "Add Launch",IDC_ADDLBUTTON,235,15,55,14
+ PUSHBUTTON "Del Sep/Launch Button",IDC_REMOVEBUTTON,180,60,100,14
+
EDITTEXT IDC_ENAME,195,111,85,14,ES_AUTOHSCROLL | WS_TABSTOP
LTEXT "Name: ",IDC_LBUTTONNAME,170,114,24,8
EDITTEXT IDC_EPATH,195,134,85,14,ES_AUTOHSCROLL | WS_TABSTOP
LTEXT "Path:",IDC_LBUTTONPATH,170,136,18,8
PUSHBUTTON "Set",IDC_LBUTTONSET,205,158,50,14
- GROUPBOX "Separator Button",IDC_STATIC,165,0,130,40
- GROUPBOX "Launch Button",IDC_STATIC,165,45,130,136
+
LTEXT "Button Height:",IDC_STATIC,11,190,46,8
EDITTEXT IDC_BUTTHEIGHT,65,187,24,14,ES_AUTOHSCROLL | WS_TABSTOP
LTEXT "Button Width: ",IDC_STATIC,11,211,46,8
diff --git a/plugins/TopToolBar/resource.h b/plugins/TopToolBar/resource.h
index 230adf88f0..9cb7f600ee 100644
--- a/plugins/TopToolBar/resource.h
+++ b/plugins/TopToolBar/resource.h
@@ -25,7 +25,7 @@
#define IDD_FRAMEPLUG2 265
#define IDC_BUTTON1 1002
#define IDC_ADDSEP 1003
-#define IDC_REMOVESEP 1004
+#define IDC_REMOVEBUTTON 1004
#define IDC_ADDLBUTTON 1005
#define IDC_DELLBUTTON 1006
#define IDC_ENAME 1007
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp
index 7e670e92ce..94131d4c62 100644
--- a/plugins/TopToolBar/toolbar.cpp
+++ b/plugins/TopToolBar/toolbar.cpp
@@ -30,9 +30,9 @@ int SetButtBitmap(int pos);
int SetAllBitmaps()
{
lockbut();
- for (int i = 0; i < nButtonsCount; i++) {
+ for (int i = 0; i < nButtonsCount; i++)
SetButtBitmap(i);
- }
+
ulockbut();
return 0;
}
@@ -56,27 +56,167 @@ int idtopos(int id)
return -1;
}
+//----- Service buttons -----
+void InsertSBut(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_ISSBUTTON;
+ ttb.wParamDown = i;
+ ttb.lParamDown = TTBAddButton(( WPARAM )&ttb, 0);;
+ CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_ALLDATA, ttb.lParamDown), (LPARAM)&ttb);
+}
+
+void LoadAllSButs()
+{
+ //must be locked
+ int cnt = DBGetContactSettingByte(0, TTB_OPTDIR, "ServiceCnt", 0);
+ if (cnt > 0)
+ {
+ for (int i = 0; i<cnt; i++)
+ InsertSBut(i);
+ }
+}
+
+//----- Launch buttons -----
+INT_PTR LaunchService(WPARAM wParam, LPARAM lParam)
+{
+ PROCESS_INFORMATION pi;
+ STARTUPINFO si = {0};
+ si.cb = sizeof(si);
+
+ if ( CreateProcess(NULL, Buttons[lParam].program, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
+ 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.pszService = TTB_LAUNCHSERVICE;
+ ttb.name = _strdup(Translate("Default"));
+ ttb.program = _tcsdup( _T("Execute Path"));
+ ttb.wParamDown = i;
+ ttb.lParamDown = TTBAddButton(( WPARAM )&ttb, 0);;
+ CallService(MS_TTB_SETBUTTONOPTIONS, MAKEWPARAM(TTBO_ALLDATA, ttb.lParamDown), (LPARAM)&ttb);
+}
+
+void LoadAllLButs()
+{
+ //must be locked
+ int cnt = DBGetContactSettingByte(0, TTB_OPTDIR, "LaunchCnt", 0);
+ for (int i = 0; i<cnt; i++)
+ InsertLBut(i);
+}
+
+//----- Separators -----
+
+static int SeparatorCnt, LaunchCnt;
+
+void InsertSeparator(int i)
+{
+ TTBButton ttb = { 0 };
+ ttb.cbSize = sizeof(ttb);
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR;
+ ttb.wParamDown = i;
+ ttb.lParamDown = TTBAddButton((WPARAM)&ttb, 0);
+ 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++)
+ InsertSeparator(i);
+}
+
int DBSaveButtonSettings(int butpos)
{
char buf[255];
- memset(buf, 0, SIZEOF(buf));
-
- DBWriteContactSettingWord(0, TTB_OPTDIR, AS(buf, Buttons[butpos].name, "_Position"), Buttons[butpos].arrangedpos);
+// memset(buf, 0, SIZEOF(buf));
- DWORD oldv = Buttons[butpos].dwFlags & TTBBF_VISIBLE;
- DBWriteContactSettingDword(0, TTB_OPTDIR, AS(buf, Buttons[butpos].name, "_Visible"), oldv);
+ TopButtonInt& b = Buttons[butpos];
+ if (b.dwFlags & TTBBF_ISSEPARATOR) {
+ char buf1[10];
+ _itoa(SeparatorCnt++, buf1, 10);
+ char buf2[20];
+ AS(buf2, "Sep", buf1);
- DBWriteContactSettingString(0, TTB_OPTDIR, AS(buf, Buttons[butpos].name, "_BmpDown"), "");
- DBWriteContactSettingString(0, TTB_OPTDIR, AS(buf, Buttons[butpos].name, "_BmpUp"), "");
+ DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), b.arrangedpos);
+ DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), b.dwFlags & TTBBF_VISIBLE);
+ }
+ else if (b.dwFlags & TTBBF_ISLBUTTON) {
+ char buf1[10];
+ _itoa(LaunchCnt++, buf1, 10);
+ char buf2[20];
+ AS(buf2, "Launch", buf1);
+
+ DBWriteContactSettingString(0, TTB_OPTDIR, AS(buf, buf2, "_name"), b.name);
+ DBWriteContactSettingTString(0, TTB_OPTDIR, AS(buf, buf2, "_lpath"), b.program);
+ DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Position"), b.arrangedpos);
+ DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, buf2, "_Visible"), b.dwFlags & TTBBF_VISIBLE);
+ }
+ else {
+ DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, b.name, "_Position"), b.arrangedpos);
+ DBWriteContactSettingByte(0, TTB_OPTDIR, AS(buf, b.name, "_Visible"), b.dwFlags & TTBBF_VISIBLE);
+ }
return 0;
}
int SaveAllButtonsOptions()
{
lockbut();
+ SeparatorCnt = 0;
+ LaunchCnt = 0;
for (int i = 0; i < nButtonsCount; i++)
DBSaveButtonSettings(i);
+ DBWriteContactSettingByte(0, TTB_OPTDIR, "SepCnt", SeparatorCnt);
+ DBWriteContactSettingByte(0, TTB_OPTDIR, "Launchcnt", LaunchCnt);
ulockbut();
return 0;
}
@@ -84,14 +224,44 @@ int SaveAllButtonsOptions()
int DBLoadButtonSettings(int butpos)
{
char buf[255];
- memset(buf, 0, SIZEOF(buf));
-
- //bool
- Buttons[butpos].arrangedpos = DBGetContactSettingWord(0, TTB_OPTDIR, AS(buf, Buttons[butpos].name, "_Position"), MAX_BUTTONS);
- DWORD oldv = Buttons[butpos].dwFlags & TTBBF_VISIBLE;
- Buttons[butpos].dwFlags = Buttons[butpos].dwFlags & (~TTBBF_VISIBLE);
- if ( DBGetContactSettingDword(0, TTB_OPTDIR, AS(buf, Buttons[butpos].name, "_Visible"), oldv) > 0 )
- Buttons[butpos].dwFlags |= TTBBF_VISIBLE;
+// memset(buf, 0, SIZEOF(buf));
+ TopButtonInt& b = Buttons[butpos];
+
+ if (b.dwFlags & TTBBF_ISSEPARATOR) {
+ if (b.wParamDown != -1) {
+ 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"), b.dwFlags & TTBBF_VISIBLE) > 0 )
+ b.dwFlags |= TTBBF_VISIBLE;
+ }
+ }
+ else if (b.dwFlags & TTBBF_ISLBUTTON) {
+ if (b.wParamDown != -1) {
+ char buf1[10];
+ _itoa(b.wParamDown, buf1, 10);
+ char buf2[20];
+ AS(buf2, "Launch", buf1);
+
+ if (b.name != NULL) free(b.name);
+ b.name = DBGetString(0, TTB_OPTDIR, AS(buf, buf2, "_name"));
+ 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"), b.dwFlags & TTBBF_VISIBLE) > 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"), b.dwFlags & TTBBF_VISIBLE) > 0 )
+ b.dwFlags |= TTBBF_VISIBLE;
+ }
return 0;
}
@@ -118,16 +288,15 @@ int ttbOptionsChanged()
ArrangeButtons();
SetAllBitmaps();
- SaveAllSeparators();
- SaveAllButtonsOptions();
+ SaveAllButtonsOptions(); //!!??
return 0;
}
-static int RemoveItemFromList(int pos, TopButtonInt *lpButtons, int *ButtonsItemCount)
+static int RemoveItemFromList(int pos, TopButtonInt *lpButtons, int &ButtonsItemCount)
{
- memcpy( &lpButtons[pos], &lpButtons[pos+1], sizeof(TopButtonInt)*(*ButtonsItemCount-pos-1));
- *ButtonsItemCount--;
+ memcpy( &lpButtons[pos], &lpButtons[pos+1], sizeof(TopButtonInt)*(ButtonsItemCount-pos-1));
+ ButtonsItemCount--;
return 0;
}
@@ -140,11 +309,18 @@ INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM lParam)
if (pos<0 || pos >= nButtonsCount){ulockbut();return -1;}
DestroyWindow(Buttons[pos].hwnd);
- if (Buttons[pos].pszServiceDown != NULL)
- free(Buttons[pos].pszServiceDown);
- if (Buttons[pos].pszServiceUp != NULL)
- free(Buttons[pos].pszServiceUp);
- RemoveItemFromList(pos, Buttons, &nButtonsCount);
+ if (Buttons[pos].dwFlags & TTBBF_ISLBUTTON)
+ {
+ if (Buttons[pos].name != NULL)
+ free(Buttons[pos].name);
+ if (Buttons[pos].program != NULL)
+ free(Buttons[pos].program);
+ }
+ else if (Buttons[pos].pszService != NULL)
+ free(Buttons[pos].pszService);
+
+ RemoveItemFromList(pos, Buttons, nButtonsCount);
+
ArrangeButtons();
ulockbut();
OptionsPageRebuild();
@@ -164,10 +340,12 @@ static int UpdateToolTip(int bpos)
bool nameexists(const char *name)
{
- for (int i = 0; i < nButtonsCount; i++)
- if (strcmp(Buttons[i].name, name) == 0)
- return TRUE;
-
+ if (name != NULL)
+ for (int i = 0; i < nButtonsCount; i++)
+ {
+ if ((Buttons[i].name != NULL) && (strcmp(Buttons[i].name, name) == 0))
+ return TRUE;
+ }
return FALSE;
}
@@ -201,7 +379,7 @@ HICON LoadIconFromLibrary(char *Name, char *Description, HICON hIcon, HANDLE* ph
int CreateOneWindow(int ButtonPos)
{
if (!(Buttons[ButtonPos].dwFlags & TTBBF_ISSEPARATOR))
- Buttons[ButtonPos].hwnd = CreateWindow(MYMIRANDABUTTONCLASS, _T(""), BS_PUSHBUTTON|WS_CHILD|WS_TABSTOP|SS_NOTIFY, 0, 0, BUTTWIDTH, BUTTHEIGHT, hwndTopToolBar, NULL, hInst, 0);
+ Buttons[ButtonPos].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);
@@ -229,7 +407,8 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
int i = nButtonsCount;
TTBButton *but = (TTBButton*)wParam;
- if (but->cbSize != sizeof(TTBButton) || but->name == NULL || nameexists(but->name)) {
+ if ((but->cbSize != sizeof(TTBButton)) ||
+ (!(but->dwFlags && TTBBF_ISLBUTTON) && nameexists(but->name))) {
ulockbut();
return -1;
}
@@ -237,9 +416,13 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
TopButtonInt& b = Buttons[i];
b.id = nextButtonId++;
- if (but->pszServiceDown != NULL) b.pszServiceDown = _strdup(but->pszServiceDown);
- if (but->pszServiceUp != NULL) b.pszServiceUp = _strdup(but->pszServiceUp);
- b.name = _strdup(but->name);
+ if (but->pszService != NULL) b.pszService = _strdup(but->pszService);
+
+ if (but->name != NULL)
+ b.name = _strdup(but->name);
+ else
+ b.name = NULL;
+
b.dwFlags = but->dwFlags;
if (b.dwFlags & TTBBF_ICONBYHANDLE) {
@@ -268,26 +451,26 @@ 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);
+ 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);
+ 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);
+ 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);
+ SendMessage(b.hwndTip, TTM_ACTIVATE, (WPARAM)(b.dwFlags&TTBBF_SHOWTOOLTIP)?TRUE:FALSE, 0);
+ }
SetWindowLongPtr(b.hwnd, GWLP_USERDATA, b.id);
@@ -429,7 +612,6 @@ int ArrangeButtons()
SetWindowPos(Buttons[arrangedbuts[i].oldpos].hwnd, 0, lastxpos, lastypos, BUTTWIDTH, BUTTHEIGHT, x);
InvalidateRect(Buttons[arrangedbuts[i].oldpos].hwnd, NULL, TRUE);
- //lastxpos += BUTTWIDTH+1;
if (i == v-1)
break;
if ( !(Buttons[arrangedbuts[i+1].oldpos].dwFlags & TTBBF_VISIBLE))
@@ -440,10 +622,8 @@ int ArrangeButtons()
if (lastxpos+w1+w2+1 > winrc.left) {
lastxpos = 1;
lastypos += BUTTHEIGHT+2;
- if (Buttons[arrangedbuts[i+1].oldpos].dwFlags & TTBBF_VISIBLE) {
- 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;
@@ -465,16 +645,16 @@ int SetButtBitmap(int pos)
curstyle &= (~SS_BITMAP);
curstyle &= (~SS_ICON);
- if (Buttons[pos].dwFlags & TTBBF_ISSEPARATOR)
- SetWindowLongPtr(Buttons[pos].hwnd, GWL_STYLE, curstyle | SS_BITMAP);
- else if (GetWindowLongPtr(Buttons[pos].hwnd, GWL_STYLE) & SS_ICON)
- SetWindowLongPtr(Buttons[pos].hwnd, GWL_STYLE, curstyle | SS_ICON);
-
if (Buttons[pos].dwFlags & TTBBF_ISSEPARATOR) {
- SendMessage(Buttons[pos].hwnd, STM_SETIMAGE, IMAGE_ICON, (LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
-//!! SendMessage(Buttons[pos].hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
+ 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);
+ }
+ 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)));
}
- else SendMessage(Buttons[pos].hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
return 0;
}
@@ -557,8 +737,7 @@ INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam)
lpTTB->lParamDown = Buttons[pos].lParamDown;
lpTTB->wParamDown = Buttons[pos].wParamDown;
- lpTTB->pszServiceDown = _strdup(Buttons[pos].pszServiceDown);
- lpTTB->pszServiceUp = _strdup(Buttons[pos].pszServiceUp);
+ lpTTB->pszService = _strdup(Buttons[pos].pszService);
retval = ( INT_PTR )lpTTB;
}
@@ -631,13 +810,10 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam)
Buttons[pos].lParamDown = lpTTB->lParamDown;
Buttons[pos].wParamDown = lpTTB->wParamDown;
- if (Buttons[pos].pszServiceDown != NULL)
- free(Buttons[pos].pszServiceDown);
- if (Buttons[pos].pszServiceUp != NULL)
- free(Buttons[pos].pszServiceUp);
+ if (Buttons[pos].pszService != NULL)
+ free(Buttons[pos].pszService);
- Buttons[pos].pszServiceDown = _strdup(lpTTB->pszServiceDown);
- Buttons[pos].pszServiceUp = _strdup(lpTTB->pszServiceUp);
+ Buttons[pos].pszService = _strdup(lpTTB->pszService);
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);
@@ -806,16 +982,16 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
Buttons[pos].bPushed = !Buttons[pos].bPushed;
SetButtBitmap(pos);
- if (Buttons[pos].pszServiceUp != NULL)
- CallService(Buttons[pos].pszServiceUp, Buttons[pos].wParamUp, Buttons[pos].lParamUp);
+ if (Buttons[pos].pszService != NULL)
+ CallService(Buttons[pos].pszService, Buttons[pos].wParamUp, Buttons[pos].lParamUp);
}
else {
//Up -> Dn
Buttons[pos].bPushed = !Buttons[pos].bPushed;
SetButtBitmap(pos);
- if (Buttons[pos].pszServiceDown != NULL)
- CallService(Buttons[pos].pszServiceDown, Buttons[pos].wParamDown, Buttons[pos].lParamDown);
+ if (Buttons[pos].pszService != NULL)
+ CallService(Buttons[pos].pszService, Buttons[pos].wParamDown, Buttons[pos].lParamDown);
}
ulockbut();
@@ -849,8 +1025,6 @@ int addTopToolBarWindow(HWND parent)
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
0, 0, 0, 0, parent, NULL, hInst, NULL);
- ttbOptionsChanged();
-
CLISTFrame Frame = { 0 };
Frame.cbSize = sizeof(Frame);
Frame.tname = pluginname;
@@ -905,10 +1079,8 @@ int OnModulesLoad(WPARAM wParam, LPARAM lParam)
hFrameTopWindow = addTopToolBarWindow(hwndContactList);
LoadInternalButtons(( HWND )CallService(MS_CLUI_GETHWNDTREE, 0, 0));
- SaveAllButtonsOptions();
-
LoadAllSeparators();
- InitLBut();
+ LoadAllLButs();
StopArrange = FALSE;
ArrangeButtons();
@@ -924,6 +1096,7 @@ int OnModulesLoad(WPARAM wParam, LPARAM lParam)
arHooks.insert( HookEvent(ME_BACKGROUNDCONFIG_CHANGED, OnBGChange));
}
+ ttbOptionsChanged();
return 0;
}
@@ -947,11 +1120,11 @@ int LoadToolbarModule()
arServices.insert( CreateServiceFunction(MS_TTB_GETBUTTONOPTIONS, TTBGetOptions));
arServices.insert( CreateServiceFunction(MS_TTB_SETBUTTONOPTIONS, TTBSetOptions));
- arServices.insert( CreateServiceFunction(TTB_ADDSEPARATOR, InsertNewFreeSeparator));
- arServices.insert( CreateServiceFunction(TTB_REMOVESEPARATOR, DeleteSeparator));
arServices.insert( CreateServiceFunction("TTB_ONSTARTUPFIRE", OnEventFire));
+ arServices.insert( CreateServiceFunction(TTB_LAUNCHSERVICE, LaunchService));
+
BUTTHEIGHT = DBGetContactSettingByte(0, TTB_OPTDIR, "BUTTHEIGHT", 16);
BUTTWIDTH = DBGetContactSettingByte(0, TTB_OPTDIR, "BUTTWIDTH", 20);
return 0;
@@ -961,8 +1134,6 @@ int LoadToolbarModule()
int UnloadToolbarModule()
{
- SaveAllSeparators();
-
DeleteObject(hBmpSeparator);
DeleteCriticalSection(&csButtonsHook);
return 0;
diff --git a/plugins/TopToolBar/ttbopt.cpp b/plugins/TopToolBar/ttbopt.cpp
index afe0f5dc82..395a02f2d5 100644
--- a/plugins/TopToolBar/ttbopt.cpp
+++ b/plugins/TopToolBar/ttbopt.cpp
@@ -2,9 +2,6 @@
#include <shlobj.h>
#pragma hdrstop
-static INT_PTR CALLBACK DlgProcTTBBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-extern int ttbOptionsChanged();
-
extern TopButtonInt Buttons[MAX_BUTTONS];
extern int nButtonsCount;
@@ -34,23 +31,35 @@ int BuildTree(HWND hwndDlg)
TVINSERTSTRUCT tvis = { 0 };
tvis.hInsertAfter = TVI_LAST;
- tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+
+ int index;
+ TCHAR* tmp;
for (int i = 0; i < nButtonsCount; i++) {
TopButtonInt &b = Buttons[arrangedbuts[i].oldpos];
- int index;
- if (b.dwFlags & TTBBF_ICONBYHANDLE) {
- HICON hIcon = Skin_GetIconByHandle(b.hIconHandleUp);
- index = ImageList_AddIcon(dat->himlButtonIcons, hIcon);
- Skin_ReleaseIcon(hIcon);
+ index = 0;
+
+ if (b.dwFlags & TTBBF_ISSEPARATOR) {
+ tvis.item.mask = TVIF_PARAM | TVIF_TEXT;
+ tmp = mir_wstrdup(L"------------------");
+ index = -1;
+ }
+ else if ( !(b.dwFlags & TTBBF_ISLBUTTON)) {
+ tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ if (b.dwFlags & TTBBF_ICONBYHANDLE) {
+ HICON hIcon = Skin_GetIconByHandle(b.hIconHandleUp);
+ index = ImageList_AddIcon(dat->himlButtonIcons, hIcon);
+ Skin_ReleaseIcon(hIcon);
+ }
+ else index = ImageList_AddIcon(dat->himlButtonIcons, b.hIconUp);
+ tvis.item.iImage = tvis.item.iSelectedImage = index;
+
+ tmp = mir_a2t( b.name );
}
- else index = ImageList_AddIcon(dat->himlButtonIcons, b.hIconUp);
- TCHAR* tmp = mir_a2t( b.name );
tvis.item.lParam = (LPARAM)&b;
tvis.item.pszText = TranslateTS(tmp);
- tvis.item.iImage = tvis.item.iSelectedImage = index;
HTREEITEM hti = TreeView_InsertItem(hTree, &tvis);
mir_free(tmp);
@@ -85,7 +94,10 @@ int SaveTree(HWND hwndDlg)
TreeView_GetItem(hTree, &tvi);
TopButtonInt* btn = (TopButtonInt*)tvi.lParam;
- if (btn->arrangedpos >= 0 && btn->arrangedpos) {
+ // can use TreeView_GetCheckState(hTree,tvi.hItem);
+ // WTF?!
+// if (btn->arrangedpos >= 0 && btn->arrangedpos)
+ {
if ((tvi.state >> 12 ) == 0x2)
btn->dwFlags |= TTBBF_VISIBLE;
else
@@ -146,6 +158,8 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
int ctrlid = LOWORD(wParam);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ //----- Launch buttons -----
+
if (ctrlid == IDC_LBUTTONSET) {
TVITEM tvi;
tvi.hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE));
@@ -156,79 +170,58 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
TreeView_GetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
btn = (TopButtonInt*)tvi.lParam;
+ TCHAR buf [256];
+ // probably, condition not needs
if (btn->dwFlags & TTBBF_ISLBUTTON) {
- LBUTOPT lbo = { 0 };
- TCHAR buf[256];
+ if (btn->name) free(btn->name);
GetDlgItemText(hwndDlg, IDC_ENAME, buf, 255);
- lbo.name = _strdup( _T2A(buf));
+ btn->name = _strdup( _T2A(buf));
+ if (btn->program) free(btn->program);
GetDlgItemText(hwndDlg, IDC_EPATH, buf, 255);
- lbo.lpath = _tcsdup(buf);
+ btn->program = _tcsdup(buf);
- CallService(TTB_MODIFYLBUTTON, btn->lParamDown, (LPARAM)&lbo);
- free(lbo.name);
- free(lbo.lpath);
+ tvi.mask = TVIF_TEXT;
+ tvi.pszText = mir_a2t( btn->name );
+ TreeView_SetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
}
break;
}
if (ctrlid == IDC_ADDLBUTTON) {
- if (CallService(TTB_ADDLBUTTON, 0, 0) == 0) {
- // BuildTree(hwndDlg);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
+ InsertLBut(-1);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
- if (ctrlid == IDC_DELLBUTTON) {
- TVITEM tvi;
- tvi.hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE));
- if (tvi.hItem == NULL)
- break;
-
- tvi.mask = TVIF_PARAM;
- TreeView_GetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
- btn = (TopButtonInt*)tvi.lParam;
-
- if (btn->dwFlags & TTBBF_ISLBUTTON) {
- CallService(TTB_REMOVELBUTTON, btn->lParamDown, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
- BuildTree(hwndDlg);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
+ //----- Separators -----
if (ctrlid == IDC_ADDSEP) {
- if (CallService(TTB_ADDSEPARATOR, 0, 0) == 0) {
- // BuildTree(hwndDlg);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
+ InsertSeparator(-1);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
- if (ctrlid == IDC_REMOVESEP) {
- TVITEM tvi;
- memset(&tvi, 0, sizeof(tvi));
+ if (ctrlid == IDC_REMOVEBUTTON) {
+ TVITEM tvi = {0};
tvi.hItem = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE));
if (tvi.hItem == NULL)
break;
tvi.mask = TVIF_PARAM;
TreeView_GetItem(GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE), &tvi);
- if (tvi.lParam == 0)
- break;
-
- if ( IsBadCodePtr(( FARPROC )tvi.lParam)) {
- MessageBoxA(0, "Bad Code Ptr: tvi.lParam", "log", 0);
- break;
- }
btn = (TopButtonInt*)tvi.lParam;
if (btn->dwFlags & TTBBF_ISSEPARATOR) {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- CallService(TTB_REMOVESEPARATOR, btn->lParamDown, 0);
+ DeleteSeparator(btn->wParamDown);
+ 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;
}
}
@@ -282,33 +275,30 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
TopButtonInt *btn = (TopButtonInt*)((LPNMTREEVIEW)lParam)->itemNew.lParam;
lockbut();
- EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVESEP), FALSE);
- if (btn->dwFlags & TTBBF_ISSEPARATOR)
- EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVESEP), TRUE);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELLBUTTON), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), FALSE);
- SetDlgItemTextA(hwndDlg, IDC_ENAME, "");
- SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
if (btn->dwFlags & TTBBF_ISLBUTTON) {
- LBUTOPT lbo = { 0 };
- CallService(TTB_GETLBUTTON, btn->lParamDown, (LPARAM)&lbo);
- if (lbo.hframe != 0) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELLBUTTON), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), TRUE);
-
- if (lbo.name != NULL)
- SetDlgItemTextA(hwndDlg, IDC_ENAME, lbo.name);
- if (lbo.lpath != NULL)
- SetDlgItemText(hwndDlg, IDC_EPATH, lbo.lpath);
- }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), TRUE);
+ if (btn->name != NULL)
+ SetDlgItemTextA(hwndDlg, IDC_ENAME, btn->name);
+ if (btn->program != NULL)
+ SetDlgItemText(hwndDlg, IDC_EPATH, btn->program);
+ }
+ else
+ {
+ if (btn->dwFlags & TTBBF_ISSEPARATOR)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), TRUE);
+ else
+ EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), FALSE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), FALSE);
+ SetDlgItemTextA(hwndDlg, IDC_ENAME, "");
+ SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
}
-
ulockbut();
}
}