diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-28 15:25:37 +0200 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-28 15:25:37 +0200 |
commit | c5f9c32622faab78f0cce5bf39993de4bed929da (patch) | |
tree | c944dbc9fc4ad69e8a16015fe06e75d24d8fe71e | |
parent | 4aac94ac3a0021307b51ee2adb3965b70d3924e9 (diff) |
TopToolBar: fixes #1306 (bunch of problems with Launch Buttons
-rw-r--r-- | plugins/TopToolBar/src/main.cpp | 2 | ||||
-rw-r--r-- | plugins/TopToolBar/src/stdafx.h | 8 | ||||
-rw-r--r-- | plugins/TopToolBar/src/toolbar.cpp | 71 | ||||
-rw-r--r-- | plugins/TopToolBar/src/toolbarwnd.cpp | 3 | ||||
-rw-r--r-- | plugins/TopToolBar/src/version.h | 2 |
5 files changed, 43 insertions, 43 deletions
diff --git a/plugins/TopToolBar/src/main.cpp b/plugins/TopToolBar/src/main.cpp index 58cc361049..3b0339e9fc 100644 --- a/plugins/TopToolBar/src/main.cpp +++ b/plugins/TopToolBar/src/main.cpp @@ -35,7 +35,7 @@ IconItem iconList[] = { LPGEN("Enable sounds"), "sounds_on", IDI_SOUNDSON },
{ LPGEN("Disable metacontacts"), "meta_off", IDI_METAON },
{ LPGEN("Enable metacontacts"), "meta_on", IDI_METAOFF },
- { LPGEN("Separator"), "separator", IDI_SEPARATOR }
+ { LPGEN("Separator"), "separator", IDI_SEPARATOR }
};
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/TopToolBar/src/stdafx.h b/plugins/TopToolBar/src/stdafx.h index 8eb1a0a881..6c3d1a676b 100644 --- a/plugins/TopToolBar/src/stdafx.h +++ b/plugins/TopToolBar/src/stdafx.h @@ -135,14 +135,8 @@ void InitInternalButtons(void); int LoadToolbarModule(void);
int UnloadToolbarModule(void);
-void SetAllBitmaps(void);
-int SaveAllLButs(void);
int SaveAllButtonsOptions(void);
-void InsertSeparator( int i );
-void DeleteSeparator(int i);
-void DeleteLBut(int i);
-void InsertLBut(int i);
-
+void LoadAllSeparators();
void LoadAllLButs();
#endif
\ No newline at end of file diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp index a0a77b8536..7201f1be7c 100644 --- a/plugins/TopToolBar/src/toolbar.cpp +++ b/plugins/TopToolBar/src/toolbar.cpp @@ -61,52 +61,60 @@ void LoadAllSButs() //----- Launch buttons -----
INT_PTR LaunchService(WPARAM, LPARAM lParam)
{
- PROCESS_INFORMATION pi;
- STARTUPINFO si = {0};
- si.cb = sizeof(si);
+ for (auto &it : Buttons) {
+ if (!(it->dwFlags & TTBBF_ISLBUTTON) || it->wParamDown != (WPARAM)lParam)
+ continue;
+
+ PROCESS_INFORMATION pi;
+ STARTUPINFO si = { 0 };
+ si.cb = sizeof(si);
- if (CreateProcess(nullptr, Buttons[lParam]->ptszProgram, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi)) {
- CloseHandle(pi.hProcess);
- CloseHandle(pi.hThread);
+ if (CreateProcess(nullptr, it->ptszProgram, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi)) {
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
+ }
+ break;
}
return 0;
}
-void InsertLBut(int i)
+void LoadAllLButs()
{
TTBButton ttb = {};
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL;
- ttb.name = LPGEN("Default");
- ttb.program = L"Execute Path";
- ttb.wParamDown = i;
- TTBAddButton((WPARAM)&ttb, 0);
-}
-void LoadAllLButs()
-{
- //must be locked
int cnt = db_get_b(0, TTB_OPTDIR, "LaunchCnt", 0);
- for (int i = 0; i < cnt; i++)
- InsertLBut(i);
+ for (int i = 0; i < cnt; i++) {
+ char buf[255], buf1[10], buf2[100];
+ _itoa(i, buf1, 10);
+ AS(buf2, "Launch", buf1);
+
+ ptrA szName(db_get_sa(0, TTB_OPTDIR, AS(buf, buf2, "_name")));
+ ptrW wszProgram(db_get_wsa(0, TTB_OPTDIR, AS(buf, buf2, "_lpath")));
+ if (szName == nullptr || wszProgram == nullptr)
+ continue;
+
+ ttb.hIconHandleDn = ttb.hIconHandleUp = iconList[0].hIcolib;
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL;
+ ttb.name = szName;
+ ttb.program = wszProgram;
+ ttb.wParamDown = i;
+ TTBAddButton((WPARAM)&ttb, 0);
+ }
}
//----- Separators -----
-void InsertSeparator(int i)
-{
- TTBButton ttb = {};
- ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL;
- ttb.wParamDown = i;
- TTBAddButton((WPARAM)&ttb, 0);
-}
void LoadAllSeparators()
{
- //must be locked
+ TTBButton ttb = {};
+
int cnt = db_get_b(0, TTB_OPTDIR, "SepCnt", 0);
- for (int i = 0; i < cnt; i++)
- InsertSeparator(i);
+ for (int i = 0; i < cnt; i++) {
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL;
+ ttb.wParamDown = i;
+ TTBAddButton((WPARAM)&ttb, 0);
+ }
}
int SaveAllButtonsOptions()
@@ -161,7 +169,7 @@ static void Icon2button(TTBButton *but, HANDLE &hIcoLib, HICON &hIcon, bool bIsU hIcon = IcoLib_GetIconByHandle(hIcoLib);
}
-TopButtonInt *CreateButton(TTBButton *but)
+TopButtonInt* CreateButton(TTBButton *but)
{
TopButtonInt *b = new TopButtonInt;
b->id = nextButtonId++;
@@ -569,9 +577,6 @@ int OnPluginUnload(WPARAM, LPARAM lParam) static int OnModulesLoad(WPARAM, LPARAM)
{
- LoadAllSeparators();
- LoadAllLButs();
-
ArrangeButtons();
Miranda_WaitOnHandle(OnEventFire);
diff --git a/plugins/TopToolBar/src/toolbarwnd.cpp b/plugins/TopToolBar/src/toolbarwnd.cpp index 40bc4cf571..e0faf32262 100644 --- a/plugins/TopToolBar/src/toolbarwnd.cpp +++ b/plugins/TopToolBar/src/toolbarwnd.cpp @@ -46,7 +46,7 @@ static void PaintToolbar(HWND hwnd) int destw, desth;
switch(backgroundBmpUse & CLBM_TYPE) {
case CLB_STRETCH:
- if (backgroundBmpUse&CLBF_PROPORTIONAL) {
+ if (backgroundBmpUse & CLBF_PROPORTIONAL) {
if (clRect.right * bmp.bmHeight < clRect.bottom * bmp.bmWidth) {
desth = clRect.bottom;
destw = desth * bmp.bmWidth/bmp.bmHeight;
@@ -260,6 +260,7 @@ void CALLBACK OnEventFire() SetWindowLongPtr(g_ctrl->hWnd, 0, (LONG_PTR)g_ctrl);
LoadBackgroundOptions();
+ LoadAllSeparators();
LoadAllLButs();
// if we're working in skinned clist, receive the standard buttons & customizations
if (g_CustomProc && g_ctrl->hWnd)
diff --git a/plugins/TopToolBar/src/version.h b/plugins/TopToolBar/src/version.h index bf9fee7f1e..72bf8ee00f 100644 --- a/plugins/TopToolBar/src/version.h +++ b/plugins/TopToolBar/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 8
#define __RELEASE_NUM 0
-#define __BUILD_NUM 4
+#define __BUILD_NUM 5
#include <stdver.h>
|