diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-09 17:53:15 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-09 17:53:15 +0000 |
commit | cee90240b1301ad373e98fe874a924fcdbb83447 (patch) | |
tree | 2a289365c84efbfd0c27eca4663294b04737d2f1 /plugins | |
parent | 132e74c3f3f5a31558b6b50be7be70e7bc283804 (diff) |
- fix for button states errors in Clist Modern;
- fix for message handling duplicates;
- fix for naming toolbar icons;
- removed duplicate icon entry in dbeditor++
git-svn-id: http://svn.miranda-ng.org/main/trunk@884 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Clist_modern/hdr/modern_commonprototypes.h | 1 | ||||
-rw-r--r-- | plugins/Clist_modern/hdr/modern_static_clui.h | 2 | ||||
-rw-r--r-- | plugins/Clist_modern/init.cpp | 1 | ||||
-rw-r--r-- | plugins/Clist_modern/modern_clistmod.cpp | 19 | ||||
-rw-r--r-- | plugins/Clist_modern/modern_sync.cpp | 77 | ||||
-rw-r--r-- | plugins/Clist_modern/modern_tbbutton.cpp | 65 | ||||
-rw-r--r-- | plugins/Clist_modern/modern_toolbar.cpp | 34 | ||||
-rw-r--r-- | plugins/Svc_dbepp/icons.cpp | 49 | ||||
-rw-r--r-- | plugins/Svc_dbepp/main.cpp | 2 | ||||
-rw-r--r-- | plugins/TopToolBar/toolbar.cpp | 41 |
10 files changed, 129 insertions, 162 deletions
diff --git a/plugins/Clist_modern/hdr/modern_commonprototypes.h b/plugins/Clist_modern/hdr/modern_commonprototypes.h index 2d0c7b5eb3..d8cb8d33e9 100644 --- a/plugins/Clist_modern/hdr/modern_commonprototypes.h +++ b/plugins/Clist_modern/hdr/modern_commonprototypes.h @@ -68,7 +68,6 @@ extern BOOL g_bTransparentFlag; extern HINSTANCE g_hInst;
extern HIMAGELIST hCListImages;
extern BOOL g_mutex_bChangingMode;
-extern HANDLE g_hMainThread;
extern DWORD g_dwMainThreadID;
extern DWORD g_dwAwayMsgThreadID;
extern DWORD g_dwGetTextAsyncThreadID;
diff --git a/plugins/Clist_modern/hdr/modern_static_clui.h b/plugins/Clist_modern/hdr/modern_static_clui.h index f54fae26c4..11e492e211 100644 --- a/plugins/Clist_modern/hdr/modern_static_clui.h +++ b/plugins/Clist_modern/hdr/modern_static_clui.h @@ -108,8 +108,6 @@ int UnhookAll(); /* Global variables */ -HANDLE g_hMainThread=NULL; - DWORD g_dwMainThreadID=0, g_dwAwayMsgThreadID=0, g_dwGetTextAsyncThreadID=0, diff --git a/plugins/Clist_modern/init.cpp b/plugins/Clist_modern/init.cpp index c1a55fc300..9a20924a46 100644 --- a/plugins/Clist_modern/init.cpp +++ b/plugins/Clist_modern/init.cpp @@ -102,7 +102,6 @@ PLUGININTERFACE int CListInitialise() fnGetAncestor = MyGetAncestor;
g_dwMainThreadID = GetCurrentThreadId();
- DuplicateHandle(GetCurrentProcess(),GetCurrentThread(),GetCurrentProcess(),&g_hMainThread,0,FALSE,DUPLICATE_SAME_ACCESS);
mir_getTMI(&tmi);
mir_getLP( &pluginInfo );
diff --git a/plugins/Clist_modern/modern_clistmod.cpp b/plugins/Clist_modern/modern_clistmod.cpp index 2b3b584e11..535ebc3737 100644 --- a/plugins/Clist_modern/modern_clistmod.cpp +++ b/plugins/Clist_modern/modern_clistmod.cpp @@ -54,8 +54,9 @@ int EventsProcessContactDoubleClick(HANDLE hContact); INT_PTR TrayIconPauseAutoHide(WPARAM wParam,LPARAM lParam);
INT_PTR ContactChangeGroup(WPARAM wParam,LPARAM lParam);
-void InitTrayMenus(void);
+void InitTrayMenus(void);
+void UninitTrayMenu();
HIMAGELIST hCListImages = NULL;
@@ -195,22 +196,20 @@ INT_PTR GetContactIcon(WPARAM wParam,LPARAM lParam) status = ID_STATUS_OFFLINE;
else
status = db_get_w((HANDLE) wParam, szProto, "Status", ID_STATUS_OFFLINE);
- res = ExtIconFromStatusMode((HANDLE)wParam,szProto,szProto == NULL?ID_STATUS_OFFLINE:status); //by FYR
- if (lParam == 0 && res != -1) res &= 0xFFFF;
- return res;
+ res = ExtIconFromStatusMode((HANDLE)wParam,szProto,szProto == NULL?ID_STATUS_OFFLINE:status); //by FYR
+ if (lParam == 0 && res != -1) res &= 0xFFFF;
+ return res;
}
-void UninitTrayMenu();
+
void UnLoadContactListModule() //unhooks noncritical events
{
- UninitTrayMenu();
- UninitCustomMenus();
+ UninitTrayMenu();
+ UninitCustomMenus();
}
int CListMod_ContactListShutdownProc(WPARAM wParam,LPARAM lParam)
{
- FreeDisplayNameCache();
- if (g_hMainThread) CloseHandle(g_hMainThread);
- g_hMainThread = NULL;
+ FreeDisplayNameCache();
return 0;
}
diff --git a/plugins/Clist_modern/modern_sync.cpp b/plugins/Clist_modern/modern_sync.cpp index 829c86c670..df3572766e 100644 --- a/plugins/Clist_modern/modern_sync.cpp +++ b/plugins/Clist_modern/modern_sync.cpp @@ -1,20 +1,22 @@ #include "hdr/modern_commonheaders.h"
#include "hdr/modern_sync.h"
-typedef struct tagSYNCCALLITEM
+struct SYNCCALLITEM
{
WPARAM wParam;
LPARAM lParam;
int nResult;
HANDLE hDoneEvent;
PSYNCCALLBACKPROC pfnProc;
-} SYNCCALLITEM;
-static void CALLBACK _SyncCallerUserAPCProc(ULONG_PTR dwParam)
+};
+
+static void CALLBACK _SyncCallerUserAPCProc(void* param)
{
- SYNCCALLITEM* item = (SYNCCALLITEM*) dwParam;
+ SYNCCALLITEM* item = (SYNCCALLITEM*)param;
item->nResult = item->pfnProc(item->wParam, item->lParam);
SetEvent(item->hDoneEvent);
}
+
static INT_PTR SyncCaller(WPARAM proc, LPARAM lParam)
{
typedef int (*P0PARAMFUNC)();
@@ -25,38 +27,25 @@ static INT_PTR SyncCaller(WPARAM proc, LPARAM lParam) LPARAM * params = (LPARAM *)lParam;
int count = params[0];
- switch (count)
- {
- case 0:
- {
- P0PARAMFUNC pfnProc = (P0PARAMFUNC)proc;
- return pfnProc();
- }
+ switch (count) {
+ case 0:
+ return ((P0PARAMFUNC)proc)();
+
case 1:
- {
- P1PARAMFUNC pfnProc = (P1PARAMFUNC)proc;
- return pfnProc((WPARAM)params[1]);
- }
+ return ((P1PARAMFUNC)proc)((WPARAM)params[1]);
+
case 2:
- {
- P2PARAMFUNC pfnProc = (P2PARAMFUNC)proc;
- return pfnProc((WPARAM)params[1],(LPARAM)params[2]);
- }
+ return ((P2PARAMFUNC)proc)((WPARAM)params[1],(LPARAM)params[2]);
+
case 3:
- {
- P3PARAMFUNC pfnProc = (P3PARAMFUNC)proc;
- return pfnProc((WPARAM)params[1],(LPARAM)params[2], (LPARAM)params[3]);
- }
+ return ((P3PARAMFUNC)proc)((WPARAM)params[1],(LPARAM)params[2], (LPARAM)params[3]);
+
case 4:
- {
- P4PARAMFUNC pfnProc = (P4PARAMFUNC)proc;
- return pfnProc((WPARAM)params[1],(LPARAM)params[2], (LPARAM)params[3], (LPARAM)params[4]);
- }
+ return ((P4PARAMFUNC)proc)((WPARAM)params[1],(LPARAM)params[2], (LPARAM)params[3], (LPARAM)params[4]);
}
return 0;
}
-
int SyncCall(void * vproc, int count, ... )
{
LPARAM params[5];
@@ -65,9 +54,8 @@ int SyncCall(void * vproc, int count, ... ) params[0] = (LPARAM)count;
va_start(va, count);
for (i=0; i < count && i < SIZEOF(params)-1; i++)
- {
params[i+1] = va_arg(va,LPARAM);
- }
+
va_end(va);
return SyncCallProxy(SyncCaller, (WPARAM)vproc, (LPARAM) params);
}
@@ -78,24 +66,20 @@ int SyncCallProxy(PSYNCCALLBACKPROC pfnProc, WPARAM wParam, LPARAM lParam, CRITI int nReturn = 0;
- if ( cs != NULL )
- {
- if ( !fnTryEnterCriticalSection ) // for poor OSes like Win98
- {
+ if ( cs != NULL ) {
+ if ( !fnTryEnterCriticalSection ) { // for poor OSes like Win98
EnterCriticalSection( cs );
int result = pfnProc( wParam, lParam );
LeaveCriticalSection( cs );
return result;
}
- if ( fnTryEnterCriticalSection( cs ))
- { //simple call (Fastest)
+ if ( fnTryEnterCriticalSection( cs )) { //simple call (Fastest)
int result = pfnProc(wParam,lParam);
LeaveCriticalSection( cs );
return result;
}
- else
- { //Window SendMessage Call(Middle)
+ else { //Window SendMessage Call(Middle)
if ( SyncCallWinProcProxy( pfnProc, wParam, lParam, nReturn ) == S_OK)
return nReturn;
}
@@ -117,7 +101,6 @@ HRESULT SyncCallWinProcProxy( PSYNCCALLBACKPROC pfnProc, WPARAM wParam, LPARAM l item.lParam = lParam;
item.pfnProc = pfnProc;
nReturn = SendMessage(pcli->hwndContactList, UM_SYNCCALL, (WPARAM)&item,0);
-
return S_OK;
}
@@ -125,20 +108,17 @@ HRESULT SyncCallAPCProxy( PSYNCCALLBACKPROC pfnProc, WPARAM wParam, LPARAM lPara {
hReturn = 0;
- if (g_hMainThread == NULL || pfnProc == NULL)
+ if (pfnProc == NULL)
return E_FAIL;
- SYNCCALLITEM item = {0};
-
- if (GetCurrentThreadId() != g_dwMainThreadID)
- {
+ if (GetCurrentThreadId() != g_dwMainThreadID) {
+ SYNCCALLITEM item = {0};
item.wParam = wParam;
item.lParam = lParam;
item.pfnProc = pfnProc;
item.hDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- QueueUserAPC(_SyncCallerUserAPCProc, g_hMainThread, (ULONG_PTR) &item);
- PostMessage(pcli->hwndContactList,WM_NULL,0,0); // let this get processed in its own time
+ CallFunctionAsync(_SyncCallerUserAPCProc, &item);
WaitForSingleObject(item.hDoneEvent, INFINITE);
CloseHandle(item.hDoneEvent);
@@ -153,10 +133,6 @@ HRESULT SyncCallAPCProxy( PSYNCCALLBACKPROC pfnProc, WPARAM wParam, LPARAM lPara return S_OK;
}
-
-
-
-
LRESULT SyncOnWndProcCall( WPARAM wParam )
{
SYNCCALLITEM *psci = (SYNCCALLITEM *)wParam;
@@ -169,4 +145,3 @@ int DoCall( PSYNCCALLBACKPROC pfnProc, WPARAM wParam, LPARAM lParam ) {
return SyncCallProxy( pfnProc, 0, lParam );
}
-
diff --git a/plugins/Clist_modern/modern_tbbutton.cpp b/plugins/Clist_modern/modern_tbbutton.cpp index d9d95e7969..ca34872e89 100644 --- a/plugins/Clist_modern/modern_tbbutton.cpp +++ b/plugins/Clist_modern/modern_tbbutton.cpp @@ -312,28 +312,27 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam if ( !PtInRect( &rcClient, ptMouse )) {
lpSBData->fHotMark = FALSE;
ReleaseCapture();
- break;
}
-
- if (lpSBData->stateId != PBS_DISABLED && lpSBData->stateId != PBS_PRESSED) {
- lpSBData->stateId = PBS_PRESSED;
- lpSBData->fHotMark = TRUE;
- InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
- if (lpSBData->fSendOnDown) {
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
- lpSBData->stateId = PBS_NORMAL;
+ else {
+ if (lpSBData->stateId != PBS_DISABLED && lpSBData->stateId != PBS_PRESSED) {
+ lpSBData->stateId = PBS_PRESSED;
+ lpSBData->fHotMark = TRUE;
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
+ if (lpSBData->fSendOnDown) {
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
+ lpSBData->stateId = PBS_NORMAL;
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
+ }
}
+ SetCapture( lpSBData->hwnd );
}
- SetCapture( lpSBData->hwnd );
- break;
}
+ lpSBData->lResult = 0;
+ return 1;
case WM_LBUTTONUP:
if ( GetCapture() == lpSBData->hwnd ) {
- int xPos = ( ( int )( short ) LOWORD( lParam ));
- int yPos = ( ( int )( short ) HIWORD( lParam ));
- POINT ptMouse = { xPos, yPos };
+ POINT ptMouse = { LOWORD(lParam), HIWORD(lParam) };
RECT rcClient;
GetClientRect( lpSBData->hwnd, &rcClient );
@@ -344,12 +343,8 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam break;
}
- if (lpSBData->bIsPushBtn) {
- if (lpSBData->bIsPushed)
- lpSBData->bIsPushed = FALSE;
- else
- lpSBData->bIsPushed = TRUE;
- }
+ if (lpSBData->bIsPushBtn)
+ lpSBData->bIsPushed = !lpSBData->bIsPushed;
if (lpSBData->stateId != PBS_DISABLED) {
// don't change states if disabled
@@ -359,11 +354,13 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam lpSBData->stateId = PBS_NORMAL;
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
}
- if ( !lpSBData->fSendOnDown && lpSBData->fHotMark)
+ if ( !lpSBData->fSendOnDown)
SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
- lpSBData->fHotMark = FALSE;
- break;
}
+ lpSBData->fHotMark = FALSE;
+ lpSBData->lResult = 0;
+ return 1;
+
case WM_MOUSEMOVE:
{
RECT rc;
@@ -397,14 +394,17 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam ReleaseCapture();
}
}
- break;
+ lpSBData->lResult = 0;
+ return 1;
case WM_NCHITTEST:
{
LRESULT lr = SendMessage(GetParent(hwndDlg), WM_NCHITTEST, wParam, lParam);
if (lr == HTLEFT || lr == HTRIGHT || lr == HTBOTTOM || lr == HTTOP || lr == HTTOPLEFT || lr == HTTOPRIGHT
- || lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT)
- return HTTRANSPARENT;
+ || lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT) {
+ lpSBData->lResult = HTTRANSPARENT;
+ return 1;
+ }
}
break;
@@ -447,11 +447,13 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam RedrawWindow(hwndDlg,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW);
}
}
- return 0;
+ return 1;
case BM_GETIMAGE:
- if (wParam == IMAGE_ICON)
- return (LRESULT)(lpSBData->hIconPrivate ? lpSBData->hIconPrivate : lpSBData->hIcon);
+ if (wParam == IMAGE_ICON) {
+ lpSBData->lResult = (LRESULT)(lpSBData->hIconPrivate ? lpSBData->hIconPrivate : lpSBData->hIcon);
+ return 1;
+ }
break;
case BM_SETIMAGE:
@@ -486,14 +488,15 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam DeleteObject(ii.hbmMask);
DeleteObject(ii.hbmColor);
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
+ lpSBData->lResult = 0;
+ return 1;
}
- else if (wParam == IMAGE_BITMAP)
+ if (wParam == IMAGE_BITMAP)
{
if (lpSBData->hIconPrivate)
DestroyIcon(lpSBData->hIconPrivate);
lpSBData->hIcon = lpSBData->hIconPrivate = NULL;
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
- return 0; // not supported
}
break;
}
diff --git a/plugins/Clist_modern/modern_toolbar.cpp b/plugins/Clist_modern/modern_toolbar.cpp index bd604e0464..5a5b0395f2 100644 --- a/plugins/Clist_modern/modern_toolbar.cpp +++ b/plugins/Clist_modern/modern_toolbar.cpp @@ -65,12 +65,15 @@ static int Modern_InitButtons(WPARAM, LPARAM) char buf[255];
mir_snprintf(buf,SIZEOF(buf),"%s%s%s", TTB_OPTDIR, BTNS[i].pszButtonID, "_dn");
- tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "ToolBar", BTNS[i].pszButtonName , _T("icons\\toolbar_icons.dll"),-BTNS[i].icoDefIdx, g_hInst, BTNS[i].defResource );
+ tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "Toolbar", BTNS[i].pszTooltipUp, _T("icons\\toolbar_icons.dll"),-BTNS[i].icoDefIdx, g_hInst, BTNS[i].defResource );
if (BTNS[i].pszTooltipDn) {
+ tbb.dwFlags |= TTBBF_ASPUSHBUTTON;
+
mir_snprintf(buf,SIZEOF(buf),"%s%s%s", TTB_OPTDIR, BTNS[i].pszButtonID, "_up");
- tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "ToolBar", BTNS[i].pszTooltipDn , _T("icons\\toolbar_icons.dll"),-(BTNS[i].icoDefIdx+1), g_hInst, BTNS[i].defResource2 );
+ tbb.hIconHandleDn = RegisterIcolibIconHandle( buf, "Toolbar", BTNS[i].pszTooltipDn, _T("icons\\toolbar_icons.dll"),-(BTNS[i].icoDefIdx+1), g_hInst, BTNS[i].defResource2 );
}
+ else tbb.hIconHandleDn = NULL;
}
else tbb.dwFlags |= TTBBF_ISSEPARATOR;
@@ -114,6 +117,26 @@ static tbdat = { 0 }; COLORREF sttGetColor(char * module, char * color, COLORREF defColor);
+static int ehhToolBarSettingsChanged(WPARAM wParam, LPARAM lParam)
+{
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
+ if ((HANDLE)wParam != NULL)
+ return 0;
+
+ if (!mir_strcmp(cws->szModule,"CList")) {
+ if (!mir_strcmp(cws->szSetting,"HideOffline"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[3].hButton, cws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED);
+ else if (!mir_strcmp(cws->szSetting,"UseGroups"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[6].hButton, cws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED);
+ }
+ else if (!mir_strcmp(cws->szModule,"Skin")) {
+ if (!mir_strcmp(cws->szSetting,"UseSound"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[7].hButton, cws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED);
+ }
+
+ return 0;
+}
+
static int ehhToolBarBackgroundSettingsChanged(WPARAM wParam, LPARAM lParam)
{
if ( tbdat.mtb_hBmpBackground) {
@@ -240,8 +263,12 @@ static LRESULT CALLBACK toolbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA Offset.y = childRect.top - MyRect.top;
SendMessage(mtbi->hWindow, BUTTONDRAWINPARENT, (WPARAM)hDC, (LPARAM)&Offset);
}
- return 1;
}
+ pMTBInfo->lResult = 0;
+ return 1;
+
+ case WM_DESTROY:
+ xpt_FreeThemeForWindow(hwnd);
}
return 0;
@@ -267,6 +294,7 @@ void CustomizeToolbar(HWND hwnd) static int Toolbar_ModulesLoaded(WPARAM, LPARAM)
{
CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)"ToolBar Background/ToolBar",0);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ehhToolBarSettingsChanged);
HookEvent(ME_BACKGROUNDCONFIG_CHANGED, ehhToolBarBackgroundSettingsChanged);
HookEvent(ME_TTB_INITBUTTONS, Modern_InitButtons);
return 0;
diff --git a/plugins/Svc_dbepp/icons.cpp b/plugins/Svc_dbepp/icons.cpp index ae77539ae0..6da3723bfe 100644 --- a/plugins/Svc_dbepp/icons.cpp +++ b/plugins/Svc_dbepp/icons.cpp @@ -79,34 +79,28 @@ HICON LoadSkinnedDBEIcon(int icon) int AddIconToList(HIMAGELIST hil, HICON hIcon)
{
-
- if (!hIcon || !hil) return 0;
+ if (!hIcon || !hil)
+ return 0;
ImageList_AddIcon(hil, hIcon);
-
return 1;
-
}
-
static PROTOCOLDESCRIPTOR **protocols = NULL;
static int protoCount = 0;
static int shift = 0;
-
void AddProtoIconsToList(HIMAGELIST hil, int newshift)
{
- HICON hIcon;
- int i;
shift = newshift;
CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&protoCount,(LPARAM)&protocols);
- for(i = 0 ;i < protoCount; i++)
- {
+ for (int i = 0; i < protoCount; i++) {
if (protocols[i]->type != PROTOTYPE_PROTOCOL)
continue;
+ HICON hIcon;
if (hIcon=LoadSkinnedProtoIcon(protocols[i]->szName, ID_STATUS_ONLINE))
AddIconToList(hil, hIcon);
else
@@ -114,49 +108,30 @@ void AddProtoIconsToList(HIMAGELIST hil, int newshift) }
}
-
int GetProtoIcon(char *szProto)
{
- int result = DEF_ICON;
- int i, n = 0;
+ if ( !protoCount || !protocols || !szProto)
+ return DEF_ICON;
- if (!protoCount || !protocols || !szProto) return result;
+ int n = 0;
- for(i = 0 ;i < protoCount; i++)
- {
+ for (int i = 0; i < protoCount; i++) {
if (protocols[i]->type != PROTOTYPE_PROTOCOL)
continue;
if (!mir_strcmp(protocols[i]->szName, szProto))
- {
- result = n + shift;
- break;
- }
+ return n + shift;
n++;
-
}
- return result;
+ return DEF_ICON;
}
-
BOOL IsProtocolLoaded(char* pszProtocolName)
{
-/*
- if (pszProtocolName && pszProtocolName[0])
- {
- int res = CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)pszProtocolName);
-
- if (res != CALLSERVICE_NOTFOUND && res)
- return TRUE;
- }
-*/
- int i;
-
- if (protoCount)
- for(i = 0 ;i < protoCount; i++)
- {
+ if (protoCount)
+ for(int i = 0; i < protoCount; i++) {
if (protocols[i]->type != PROTOTYPE_PROTOCOL)
continue;
diff --git a/plugins/Svc_dbepp/main.cpp b/plugins/Svc_dbepp/main.cpp index 9b0a2bfc8d..b10a7e79fd 100644 --- a/plugins/Svc_dbepp/main.cpp +++ b/plugins/Svc_dbepp/main.cpp @@ -157,7 +157,7 @@ static int OnTTBLoaded(WPARAM wParam,LPARAM lParam) ttbb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
ttbb.pszService = "DBEditorpp/MenuCommand";
ttbb.name = "Database Editor++";
- ttbb.hIconUp = ttbb.hIconDn = ico;
+ ttbb.hIconUp = ico;
ttbb.pszTooltipUp = "Show DataBase Editor";
hTTBButt = TopToolbar_AddButton(&ttbb);
return 0;
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp index 81772f9ae4..6f090dcc0d 100644 --- a/plugins/TopToolBar/toolbar.cpp +++ b/plugins/TopToolBar/toolbar.cpp @@ -263,23 +263,20 @@ TopButtonInt* CreateButton(TTBButton* but) b->name = NULL;
if (b->dwFlags & TTBBF_ICONBYHANDLE) {
- if (but->hIconHandleDn)
- b->hIconDn = Skin_GetIconByHandle(but->hIconHandleDn);
+ b->hIconUp = Skin_GetIconByHandle(b->hIconHandleUp = but->hIconHandleUp);
+ if (but->hIconHandleDn)
+ b->hIconDn = Skin_GetIconByHandle(b->hIconHandleDn = but->hIconHandleDn);
else
- b->hIconDn = 0;
- b->hIconUp = Skin_GetIconByHandle(but->hIconHandleUp);
+ b->hIconDn = 0, b->hIconHandleDn = 0;
}
else {
- b->hIconDn = but->hIconDn;
- b->hIconUp = but->hIconUp;
- }
-
- char buf[256];
- sprintf(buf, "%s_up", b->name);
- b->hIconUp = LoadIconFromLibrary(buf, b->hIconUp, b->hIconHandleUp);
- if (b->hIconDn) {
- sprintf(buf, "%s_dn", b->name);
- b->hIconDn = LoadIconFromLibrary(buf, b->hIconDn, b->hIconHandleDn);
+ char buf[256];
+ mir_snprintf(buf, SIZEOF(buf), (b->hIconDn) ? "%s_up" : "%s", b->name);
+ b->hIconUp = LoadIconFromLibrary(buf, but->hIconUp, b->hIconHandleUp);
+ if (b->hIconDn) {
+ mir_snprintf(buf, SIZEOF(buf), "%s_dn", b->name);
+ b->hIconDn = LoadIconFromLibrary(buf, but->hIconDn, b->hIconHandleDn);
+ }
}
if (but->cbSize > OLD_TBBUTTON_SIZE) {
@@ -696,8 +693,8 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_COMMAND:
switch (HIWORD(wParam)) {
- case STN_CLICKED:
- case STN_DBLCLK:
+ case BN_CLICKED:
+ case BN_DOUBLECLICKED:
{
int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA);
if (id != 0) {
@@ -706,21 +703,15 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara if (b == NULL || b->isSep())
return 0;
- // flag inversion inside condition coz we uses Up -> Down for non-push buttons
- // condition and inversion can be moved to main condition end
- if (b->bPushed) { //Dn -> Up
-
- if (b->dwFlags & TTBBF_ASPUSHBUTTON)
- b->bPushed = !b->bPushed;
+ if (b->dwFlags & TTBBF_ASPUSHBUTTON)
+ b->bPushed = !b->bPushed;
+ if (b->bPushed) { //Dn -> Up
if (!(b->dwFlags & TTBBF_ISLBUTTON)) // must be always true
if (b->pszService != NULL)
CallService(b->pszService, b->wParamUp, b->lParamUp);
}
else { //Up -> Dn
- if (b->dwFlags & TTBBF_ASPUSHBUTTON)
- b->bPushed = !b->bPushed;
-
if (b->pszService != NULL)
CallService(b->pszService, b->wParamDown, b->lParamDown);
}
|