summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin10/mir_full.sln9
-rw-r--r--plugins/TopToolBar/BkgrCfg.h18
-rw-r--r--plugins/TopToolBar/CLCButton.c624
-rw-r--r--plugins/TopToolBar/ClassDiagram1.cd1
-rw-r--r--plugins/TopToolBar/InternalButtons.c436
-rw-r--r--plugins/TopToolBar/TopToolBar.sln26
-rw-r--r--plugins/TopToolBar/TopToolBar.vcxproj335
-rw-r--r--plugins/TopToolBar/TopToolBar.vcxproj.filters184
-rw-r--r--plugins/TopToolBar/_button.c515
-rw-r--r--plugins/TopToolBar/afxres.h2
-rw-r--r--plugins/TopToolBar/bmp/bitmap1.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/bmp00001.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/bmp00002.bmpbin0 -> 1270 bytes
-rw-r--r--plugins/TopToolBar/bmp/borderup.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/borederdn.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/cpaneldn.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/cpanelup.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/findusedn.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/finduser.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/finduserdn.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/groupdn.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/groupup.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/launch.bmpbin0 -> 1244 bytes
-rw-r--r--plugins/TopToolBar/bmp/launchdn.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/launchup.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/menudn.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/menuup.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/minimize.bmpbin0 -> 1252 bytes
-rw-r--r--plugins/TopToolBar/bmp/minimizedn.bmpbin0 -> 1232 bytes
-rw-r--r--plugins/TopToolBar/bmp/options.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/searchtest.bmpbin0 -> 1370 bytes
-rw-r--r--plugins/TopToolBar/bmp/sep.bmpbin0 -> 1194 bytes
-rw-r--r--plugins/TopToolBar/bmp/separator.bmpbin0 -> 512 bytes
-rw-r--r--plugins/TopToolBar/bmp/soundsdn.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/soundsup.bmpbin0 -> 1398 bytes
-rw-r--r--plugins/TopToolBar/bmp/test.bmpbin0 -> 1270 bytes
-rw-r--r--plugins/TopToolBar/button.c541
-rw-r--r--plugins/TopToolBar/buttonopt.c340
-rw-r--r--plugins/TopToolBar/common.h150
-rw-r--r--plugins/TopToolBar/find.icobin0 -> 1406 bytes
-rw-r--r--plugins/TopToolBar/icos/Find_Add Contacts_DN.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Find_Add Contacts_UP.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Groups On_Off_DN.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Groups On_Off_UP.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Minimize Button_DN.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Minimize Button_UP.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Run.icobin0 -> 1406 bytes
-rw-r--r--plugins/TopToolBar/icos/Show Main Menu_DN.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Show Main Menu_UP.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Show Options Page_DN.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Show Options Page_UP.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Show only Online Users_DN.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Show only Online Users_UP.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Sounds Enable_Disable_DN.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/Sounds Enable_Disable_UP.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/icon1.icobin0 -> 2038 bytes
-rw-r--r--plugins/TopToolBar/icos/mirandad.icobin0 -> 2294 bytes
-rw-r--r--plugins/TopToolBar/icos/mirandau.icobin0 -> 2294 bytes
-rw-r--r--plugins/TopToolBar/icos/notick.icobin0 -> 318 bytes
-rw-r--r--plugins/TopToolBar/icos/notick1.icobin0 -> 318 bytes
-rw-r--r--plugins/TopToolBar/launchbt.c211
-rw-r--r--plugins/TopToolBar/main.c1515
-rw-r--r--plugins/TopToolBar/main.rc331
-rw-r--r--plugins/TopToolBar/resource.h95
-rw-r--r--plugins/TopToolBar/separators.c111
-rw-r--r--plugins/TopToolBar/ttb-readme.txt160
-rw-r--r--plugins/TopToolBar/ttbopt.c970
67 files changed, 6574 insertions, 0 deletions
diff --git a/bin10/mir_full.sln b/bin10/mir_full.sln
index 9cfe5b7a9d..71b9dfd0ae 100644
--- a/bin10/mir_full.sln
+++ b/bin10/mir_full.sln
@@ -298,6 +298,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Twitter", "..\protocols\Twi
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChangeKeyboardLayout", "..\plugins\ChangeKeyboardLayout\ChangeKeyboardLayout.vcxproj", "{D85D47E7-EAD3-71E0-EE3A-49A7821D4DE4}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TopToolBar", "..\plugins\TopToolBar\TopToolBar.vcxproj", "{ECE691D0-BFB3-483B-A699-084269EFCE89}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -1494,6 +1496,13 @@ Global
{D85D47E7-EAD3-71E0-EE3A-49A7821D4DE4}.Release|Win32.Build.0 = Release|Win32
{D85D47E7-EAD3-71E0-EE3A-49A7821D4DE4}.Release|x64.ActiveCfg = Release|x64
{D85D47E7-EAD3-71E0-EE3A-49A7821D4DE4}.Release|x64.Build.0 = Release|x64
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|Win32.ActiveCfg = Debug|Win32
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|Win32.Build.0 = Debug|Win32
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|x64.ActiveCfg = Debug|x64
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|x64.Build.0 = Debug|x64
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|Win32.ActiveCfg = Release|Win32
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|Win32.Build.0 = Release|Win32
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|x64.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/plugins/TopToolBar/BkgrCfg.h b/plugins/TopToolBar/BkgrCfg.h
new file mode 100644
index 0000000000..a47b53a603
--- /dev/null
+++ b/plugins/TopToolBar/BkgrCfg.h
@@ -0,0 +1,18 @@
+//
+// Register of plugin's user
+//
+// wParam = (WPARAM)szSetting - string that describes a user
+// format: Category/ModuleName,
+// eg: "Contact list background/CLUI",
+// "Status bar background/StatusBar"
+// lParam = (LPARAM)dwFlags
+//
+#define MS_BACKGROUNDCONFIG_REGISTER "BkgrCfg/Register"
+
+//
+// Notification about changed background
+// wParam = ModuleName
+// lParam = 0
+#define ME_BACKGROUNDCONFIG_CHANGED "BkgrCfg/Changed"
+
+#define CLBF_TILEVTOROWHEIGHT 0x0100
diff --git a/plugins/TopToolBar/CLCButton.c b/plugins/TopToolBar/CLCButton.c
new file mode 100644
index 0000000000..597bb67cc2
--- /dev/null
+++ b/plugins/TopToolBar/CLCButton.c
@@ -0,0 +1,624 @@
+/*
+Miranda IM
+Copyright (C) 2002 Robert Rainwater
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "common.h"
+
+// TODO:
+// - Support for bitmap buttons (simple call to DrawIconEx())
+extern HINSTANCE hInst;
+LONG g_cxsmIcon, g_cysmIcon;
+
+static LRESULT CALLBACK TSButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+typedef struct {
+ HWND hwnd;
+ int stateId; // button state
+ int focus; // has focus (1 or 0)
+ HFONT hFont; // font
+ HICON arrow; // uses down arrow
+ int defbutton; // default button
+ HICON hIcon, hIconPrivate;
+ HBITMAP hBitmap;
+ int pushBtn;
+ int pbState;
+ HANDLE hThemeButton;
+ HANDLE hThemeToolbar;
+ BOOL bThemed;
+ char cHot;
+ int flatBtn;
+ char szText[128];
+ SIZE sLabel;
+ HIMAGELIST hIml;
+ int iIcon;
+} MButtonCtrl;
+
+// External theme methods and properties
+static HMODULE themeAPIHandle = NULL; // handle to uxtheme.dll
+static HANDLE (WINAPI *MyOpenThemeData)(HWND, LPCWSTR);
+static HRESULT (WINAPI *MyCloseThemeData)(HANDLE);
+static BOOL (WINAPI *MyIsThemeBackgroundPartiallyTransparent)(HANDLE, int,
+ int);
+static HRESULT (WINAPI *MyDrawThemeParentBackground)(HWND, HDC, RECT *);
+static HRESULT (WINAPI *MyDrawThemeBackground)(HANDLE, HDC, int, int,
+ const RECT *, const RECT *);
+static HRESULT (WINAPI *MyDrawThemeText)(HANDLE, HDC, int, int, LPCWSTR, int,
+ DWORD, DWORD, const RECT *);
+
+static CRITICAL_SECTION csTips;
+static HWND hwndToolTips = NULL;
+
+int UnloadTSButtonModule(WPARAM wParam, LPARAM lParam)
+{
+ DeleteCriticalSection(&csTips);
+ return 0;
+}
+
+int LoadCLCButtonModule(void)
+{
+ WNDCLASSEXA wc;
+
+ g_cxsmIcon=GetSystemMetrics(SM_CXSMICON);
+ g_cysmIcon=GetSystemMetrics(SM_CYSMICON);
+
+ ZeroMemory(&wc, sizeof(wc));
+ wc.cbSize = sizeof(wc);
+ wc.lpszClassName = "CLCButtonClass";
+ wc.lpfnWndProc = TSButtonWndProc;
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.cbWndExtra = sizeof(MButtonCtrl *);
+ wc.hbrBackground = 0;
+ wc.style = CS_GLOBALCLASS;
+ RegisterClassExA(&wc);
+ InitializeCriticalSection(&csTips);
+ return 0;
+}
+
+// Used for our own cheap TrackMouseEvent
+#define BUTTON_POLLID 100
+#define BUTTON_POLLDELAY 50
+
+#define MGPROC(x) GetProcAddress(themeAPIHandle,x)
+static int ThemeSupport()
+{
+ if (IsWinVerXPPlus()) {
+ if (!themeAPIHandle) {
+ themeAPIHandle = GetModuleHandleA("uxtheme");
+ if (themeAPIHandle) {
+ MyOpenThemeData = (HANDLE(WINAPI *)(HWND, LPCWSTR))MGPROC("OpenThemeData");
+ MyCloseThemeData = (HRESULT(WINAPI *)(HANDLE))MGPROC("CloseThemeData");
+ MyIsThemeBackgroundPartiallyTransparent = (BOOL(WINAPI *)(HANDLE, int, int))MGPROC("IsThemeBackgroundPartiallyTransparent");
+ MyDrawThemeParentBackground = (HRESULT(WINAPI *)(HWND, HDC, RECT *))MGPROC("DrawThemeParentBackground");
+ MyDrawThemeBackground = (HRESULT(WINAPI *)(HANDLE, HDC, int, int, const RECT *, const RECT *))MGPROC("DrawThemeBackground");
+ MyDrawThemeText = (HRESULT(WINAPI *)(HANDLE, HDC, int, int, LPCWSTR, int, DWORD, DWORD, const RECT *))MGPROC("DrawThemeText");
+ }
+ }
+ // Make sure all of these methods are valid (i would hope either all or none work)
+ if (MyOpenThemeData && MyCloseThemeData && MyIsThemeBackgroundPartiallyTransparent && MyDrawThemeParentBackground && MyDrawThemeBackground && MyDrawThemeText) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void DestroyTheme(MButtonCtrl *ctl)
+{
+ if (ThemeSupport()) {
+ if (ctl->hThemeButton) {
+ MyCloseThemeData(ctl->hThemeButton);
+ ctl->hThemeButton = NULL;
+ }
+ if (ctl->hThemeToolbar) {
+ MyCloseThemeData(ctl->hThemeToolbar);
+ ctl->hThemeToolbar = NULL;
+ }
+ }
+}
+
+static void LoadTheme(MButtonCtrl *ctl)
+{
+ if (ThemeSupport()) {
+ DestroyTheme(ctl);
+ ctl->hThemeButton = MyOpenThemeData(ctl->hwnd, L"BUTTON");
+ ctl->hThemeToolbar = MyOpenThemeData(ctl->hwnd, L"TOOLBAR");
+ ctl->bThemed = TRUE;
+ }
+}
+
+static TBStateConvert2Flat(int state)
+{
+ switch (state) {
+ case PBS_NORMAL:
+ return TS_NORMAL;
+ case PBS_HOT:
+ return TS_HOT;
+ case PBS_PRESSED:
+ return TS_PRESSED;
+ case PBS_DISABLED:
+ return TS_DISABLED;
+ case PBS_DEFAULTED:
+ return TS_NORMAL;
+ }
+ return TS_NORMAL;
+}
+
+static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint)
+{
+ if (hdcPaint) {
+ HDC hdcMem;
+ HBITMAP hbmMem;
+ HDC hOld;
+ RECT rcClient;
+ HFONT hOldFont = 0;
+
+ GetClientRect(ctl->hwnd, &rcClient);
+ hdcMem = CreateCompatibleDC(hdcPaint);
+ hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top);
+ hOld = SelectObject(hdcMem, hbmMem);
+
+ // If its a push button, check to see if it should stay pressed
+ if (ctl->pushBtn && ctl->pbState)
+ ctl->stateId = PBS_PRESSED;
+
+ // Draw the flat button
+ if (ctl->flatBtn) {
+ if (ctl->hThemeToolbar && ctl->bThemed) {
+ RECT rc = rcClient;
+ int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED;
+ if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) {
+ MyDrawThemeParentBackground(ctl->hwnd, hdcMem, &rc);
+ }
+ MyDrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rc, &rc);
+ } else {
+ HBRUSH hbr;
+ RECT rc = rcClient;
+
+ if (ctl->stateId == PBS_PRESSED || ctl->stateId == PBS_HOT)
+ hbr = GetSysColorBrush(COLOR_3DFACE);
+ else {
+ HDC dc;
+ HWND hwndParent;
+
+ hwndParent = GetParent(ctl->hwnd);
+ dc = GetDC(hwndParent);
+ hbr = (HBRUSH) SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM) dc, (LPARAM) hwndParent);
+ ReleaseDC(hwndParent, dc);
+ }
+ if (hbr) {
+ FillRect(hdcMem, &rc, hbr);
+ DeleteObject(hbr);
+ }
+ if (ctl->stateId == PBS_HOT || ctl->focus) {
+ if (ctl->pbState)
+ DrawEdge(hdcMem, &rc, EDGE_ETCHED, BF_RECT | BF_SOFT);
+ else
+ DrawEdge(hdcMem, &rc, BDR_RAISEDOUTER, BF_RECT | BF_SOFT);
+ } else if (ctl->stateId == PBS_PRESSED)
+ DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT | BF_SOFT);
+ }
+ } else {
+ // Draw background/border
+ if (ctl->hThemeButton && ctl->bThemed) {
+ int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED;
+ if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) {
+ MyDrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient);
+ }
+ MyDrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient);
+ } else {
+ UINT uState = DFCS_BUTTONPUSH | ((ctl->stateId == PBS_HOT) ? DFCS_HOT : 0) | ((ctl->stateId == PBS_PRESSED) ? DFCS_PUSHED : 0);
+ if (ctl->defbutton && ctl->stateId == PBS_NORMAL)
+ uState |= DLGC_DEFPUSHBUTTON;
+ DrawFrameControl(hdcMem, &rcClient, DFC_BUTTON, uState);
+ }
+
+ // Draw focus rectangle if button has focus
+ if (ctl->focus) {
+ RECT focusRect = rcClient;
+ InflateRect(&focusRect, -3, -3);
+ DrawFocusRect(hdcMem, &focusRect);
+ }
+ }
+
+ // If we have an icon or a bitmap, ignore text and only draw the image on the button
+ if (ctl->hIcon || ctl->hIconPrivate || ctl->iIcon) {
+ int ix = (rcClient.right - rcClient.left) / 2 - (g_cxsmIcon / 2);
+ int iy = (rcClient.bottom - rcClient.top) / 2 - (g_cxsmIcon / 2);
+ HICON hIconNew = ctl->hIconPrivate != 0 ? ctl->hIconPrivate : ctl->hIcon;
+ if (lstrlenA(ctl->szText) == 0) {
+ if (ctl->iIcon)
+ ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, g_cxsmIcon, g_cysmIcon, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ else
+ DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED);
+ ctl->sLabel.cx = ctl->sLabel.cy = 0;
+ } else {
+ hOldFont = SelectObject(hdcMem, ctl->hFont);
+ GetTextExtentPoint32A(hdcMem, ctl->szText, lstrlenA(ctl->szText), &ctl->sLabel);
+ ix = (rcClient.right - rcClient.left) / 2 - ((g_cxsmIcon + ctl->sLabel.cx + 4) / 2);
+ if (ctl->iIcon)
+ ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, g_cxsmIcon, g_cysmIcon, CLR_NONE, CLR_NONE, ILD_NORMAL);
+ else
+ DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED);
+ ctl->sLabel.cx += (g_cxsmIcon + 4);
+ }
+ } else if (ctl->hBitmap) {
+ BITMAP bminfo;
+ int ix, iy;
+
+ GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo);
+ ix = (rcClient.right - rcClient.left) / 2 - (bminfo.bmWidth / 2);
+ iy = (rcClient.bottom - rcClient.top) / 2 - (bminfo.bmHeight / 2);
+ if (ctl->stateId == PBS_PRESSED) {
+ ix++;
+ iy++;
+ }
+ DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->hBitmap, 0, ix, iy, bminfo.bmWidth, bminfo.bmHeight, IsWindowEnabled(ctl->hwnd) ? DST_BITMAP : DST_BITMAP | DSS_DISABLED);
+ }
+ if (GetWindowTextLengthA(ctl->hwnd)) {
+ // Draw the text and optinally the arrow
+ RECT rcText;
+
+ CopyRect(&rcText, &rcClient);
+ SetBkMode(hdcMem, TRANSPARENT);
+ // XP w/themes doesn't used the glossy disabled text. Is it always using COLOR_GRAYTEXT? Seems so.
+ SetTextColor(hdcMem, IsWindowEnabled(ctl->hwnd) || !ctl->hThemeButton ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_GRAYTEXT));
+ if (ctl->arrow)
+ DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->arrow, 0, rcClient.right - rcClient.left - 5 - g_cxsmIcon + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), (rcClient.bottom - rcClient.top) / 2 - g_cysmIcon / 2 + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON : DST_ICON | DSS_DISABLED);
+ SelectObject(hdcMem, ctl->hFont);
+ DrawStateA(hdcMem, NULL, NULL, (LPARAM) ctl->szText, 0, (rcText.right - rcText.left - ctl->sLabel.cx) / 2 + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0) + g_cxsmIcon + 4, ctl->hThemeButton ? (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + 1 : (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + (ctl->stateId == PBS_PRESSED ? 1 : 0), ctl->sLabel.cx, ctl->sLabel.cy, IsWindowEnabled(ctl->hwnd) || ctl->hThemeButton ? DST_PREFIXTEXT | DSS_NORMAL : DST_PREFIXTEXT | DSS_DISABLED);
+ }
+ if (hOldFont)
+ SelectObject(hdcMem, hOldFont);
+ BitBlt(hdcPaint, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, hdcMem, 0, 0, SRCCOPY);
+ SelectObject(hdcMem, hOld);
+ DeleteObject(hbmMem);
+ DeleteDC(hdcMem);
+ }
+}
+
+static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ MButtonCtrl *bct = (MButtonCtrl *) GetWindowLong(hwndDlg, 0);
+ switch (msg) {
+ case WM_NCCREATE:
+ {
+ SetWindowLong(hwndDlg, GWL_STYLE, GetWindowLong(hwndDlg, GWL_STYLE) | BS_OWNERDRAW);
+ bct = malloc(sizeof(MButtonCtrl));
+ if (bct == NULL)
+ return FALSE;
+ bct->hwnd = hwndDlg;
+ bct->stateId = PBS_NORMAL;
+ bct->focus = 0;
+ bct->hFont = GetStockObject(DEFAULT_GUI_FONT);
+ bct->arrow = NULL;
+ bct->defbutton = 0;
+ bct->hIcon = bct->hIconPrivate = 0;
+ bct->iIcon = 0;
+ bct->hIml = 0;
+ bct->hBitmap = NULL;
+ bct->pushBtn = 0;
+ bct->pbState = 0;
+ bct->hThemeButton = NULL;
+ bct->hThemeToolbar = NULL;
+ bct->cHot = 0;
+ bct->flatBtn = 0;
+ bct->bThemed = FALSE;
+ LoadTheme(bct);
+ SetWindowLong(hwndDlg, 0, (LONG) bct);
+ if (((CREATESTRUCTA *) lParam)->lpszName)
+ SetWindowTextA(hwndDlg, ((CREATESTRUCTA *) lParam)->lpszName);
+ return TRUE;
+ }
+ case WM_DESTROY:
+ {
+ if (bct) {
+ EnterCriticalSection(&csTips);
+ if (hwndToolTips) {
+ TOOLINFO ti;
+
+ ZeroMemory(&ti, sizeof(ti));
+ ti.cbSize = sizeof(ti);
+ ti.uFlags = TTF_IDISHWND;
+ ti.hwnd = bct->hwnd;
+ ti.uId = (UINT) bct->hwnd;
+ if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti)) {
+ SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti);
+ }
+ if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM) &ti) == 0) {
+ DestroyWindow(hwndToolTips);
+ hwndToolTips = NULL;
+ }
+ }
+ if (bct->hIconPrivate)
+ DestroyIcon(bct->hIconPrivate);
+ LeaveCriticalSection(&csTips);
+ DestroyTheme(bct);
+ free(bct);
+ }
+ SetWindowLong(hwndDlg, 0, (LONG) NULL);
+ break; // DONT! fall thru
+ }
+ case WM_SETTEXT:
+ {
+ bct->cHot = 0;
+ if ((char*) lParam) {
+ char *tmp = (char *) lParam;
+ while (*tmp) {
+ if (*tmp == '&' && *(tmp + 1)) {
+ bct->cHot = tolower(*(tmp + 1));
+ break;
+ }
+ tmp++;
+ }
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ strncpy(bct->szText, (char*) lParam, 127);
+ bct->szText[127] = 0;
+ }
+ break;
+ }
+ case WM_SYSKEYUP:
+ if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int) wParam)) {
+ if (bct->pushBtn) {
+ if (bct->pbState)
+ bct->pbState = 0;
+ else
+ bct->pbState = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
+ return 0;
+ }
+ break;
+ case WM_THEMECHANGED:
+ {
+ // themed changed, reload theme object
+ if (bct->bThemed)
+ LoadTheme(bct);
+ InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it
+ break;
+ }
+ case WM_SETFONT:
+ // remember the font so we can use it later
+ {
+ bct->hFont = (HFONT) wParam; // maybe we should redraw?
+ break;
+ }
+ case WM_NCPAINT:
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ HDC hdcPaint;
+
+ hdcPaint = BeginPaint(hwndDlg, &ps);
+ if (hdcPaint) {
+ PaintWorker(bct, hdcPaint);
+ EndPaint(hwndDlg, &ps);
+ }
+ break;
+ }
+ case BM_SETIMAGE:
+ bct->hIml = 0;
+ bct->iIcon = 0;
+ if (wParam == IMAGE_ICON) {
+ ICONINFO ii;
+ BITMAP bm;
+
+ if (bct->hIconPrivate)
+ DestroyIcon(bct->hIconPrivate);
+
+ GetIconInfo((HICON) lParam, &ii);
+ GetObject(ii.hbmColor, sizeof(bm), &bm);
+ if (bm.bmWidth > g_cxsmIcon || bm.bmHeight > g_cysmIcon) {
+ HIMAGELIST hImageList;
+ hImageList = ImageList_Create(g_cxsmIcon, g_cysmIcon, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0);
+ ImageList_AddIcon(hImageList, (HICON) lParam);
+ bct->hIconPrivate = ImageList_GetIcon(hImageList, 0, ILD_NORMAL);
+ ImageList_RemoveAll(hImageList);
+ ImageList_Destroy(hImageList);
+ bct->hIcon = 0;
+ } else {
+ bct->hIcon = (HICON) lParam;
+ bct->hIconPrivate = 0;
+ }
+
+ DeleteObject(ii.hbmMask);
+ DeleteObject(ii.hbmColor);
+ bct->hBitmap = NULL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ } else if (wParam == IMAGE_BITMAP) {
+ bct->hBitmap = (HBITMAP) lParam;
+ if (bct->hIconPrivate)
+ DestroyIcon(bct->hIconPrivate);
+ bct->hIcon = bct->hIconPrivate = NULL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ case BM_SETPRIVATEICON:
+ bct->hIml = 0;
+ bct->iIcon = 0; {
+ if (bct->hIconPrivate)
+ DestroyIcon(bct->hIconPrivate);
+ bct->hIconPrivate = DuplicateIcon(hInst, (HICON) lParam);
+ bct->hIcon = 0;
+ break;
+ }
+ case BM_SETIMLICON:
+ {
+ if (bct->hIconPrivate)
+ DestroyIcon(bct->hIconPrivate);
+ bct->hIml = (HIMAGELIST) wParam;
+ bct->iIcon = (int) lParam;
+ bct->hIcon = bct->hIconPrivate = 0;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ }
+ case BM_SETCHECK:
+ if (!bct->pushBtn)
+ break;
+ if (wParam == BST_CHECKED) {
+ bct->pbState = 1;
+ bct->stateId = PBS_PRESSED;
+ } else if (wParam == BST_UNCHECKED) {
+ bct->pbState = 0;
+ bct->stateId = PBS_NORMAL;
+ }
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BM_GETCHECK:
+ if (bct->pushBtn) {
+ return bct->pbState ? BST_CHECKED : BST_UNCHECKED;
+ }
+ return 0;
+ case BUTTONSETARROW:
+ // turn arrow on/off
+ if (wParam) {
+ //if (!bct->arrow) bct->arrow = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MINIMIZE), IMAGE_ICON, g_cxsmIcon, g_cysmIcon, 0);
+ } else {
+ if (bct->arrow) {
+ DestroyIcon(bct->arrow);
+ bct->arrow = NULL;
+ }
+ }
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONSETDEFAULT:
+ bct->defbutton = wParam ? 1 : 0;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONSETASPUSHBTN:
+ bct->pushBtn = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONSETASFLATBTN:
+ bct->flatBtn = lParam == 0 ? 1 : 0;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONSETASFLATBTN + 10:
+ bct->bThemed = lParam ? TRUE : FALSE;
+ break;
+ case BUTTONADDTOOLTIP:
+ {
+ TOOLINFOA ti;
+
+ if (!(char*) wParam)
+ break;
+ EnterCriticalSection(&csTips);
+ if (!hwndToolTips) {
+ hwndToolTips = CreateWindowExA(WS_EX_TOPMOST, TOOLTIPS_CLASSA, "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
+ }
+ ZeroMemory(&ti, sizeof(ti));
+ ti.cbSize = sizeof(ti);
+ ti.uFlags = TTF_IDISHWND;
+ ti.hwnd = bct->hwnd;
+ ti.uId = (UINT) bct->hwnd;
+ if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti)) {
+ SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti);
+ }
+ ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
+ ti.uId = (UINT) bct->hwnd;
+ ti.lpszText = (char*) wParam;
+ SendMessageA(hwndToolTips, TTM_ADDTOOLA, 0, (LPARAM) &ti);
+ LeaveCriticalSection(&csTips);
+ break;
+ }
+ case WM_SETFOCUS:
+ // set keybord focus and redraw
+ bct->focus = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case WM_KILLFOCUS:
+ // kill focus and redraw
+ bct->focus = 0;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case WM_WINDOWPOSCHANGED:
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case WM_ENABLE:
+ // windows tells us to enable/disable
+ {
+ bct->stateId = wParam ? PBS_NORMAL : PBS_DISABLED;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ }
+ case WM_MOUSELEAVE:
+ // faked by the WM_TIMER
+ {
+ if (bct->stateId != PBS_DISABLED) {
+ // don't change states if disabled
+ bct->stateId = PBS_NORMAL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ }
+ case WM_LBUTTONDOWN:
+ {
+ if (bct->stateId != PBS_DISABLED) {
+ // don't change states if disabled
+ bct->stateId = PBS_PRESSED;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ }
+ case WM_LBUTTONUP:
+ {
+ if (bct->pushBtn) {
+ if (bct->pbState)
+ bct->pbState = 0;
+ else
+ bct->pbState = 1;
+ }
+ if (bct->stateId != PBS_DISABLED) {
+ // don't change states if disabled
+ if (msg == WM_LBUTTONUP)
+ bct->stateId = PBS_HOT;
+ else
+ bct->stateId = PBS_NORMAL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ // Tell your daddy you got clicked.
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
+ break;
+ }
+ case WM_MOUSEMOVE:
+ if (bct->stateId == PBS_NORMAL) {
+ bct->stateId = PBS_HOT;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ // Call timer, used to start cheesy TrackMouseEvent faker
+ SetTimer(hwndDlg, BUTTON_POLLID, BUTTON_POLLDELAY, NULL);
+ break;
+ case WM_TIMER:
+ // use a timer to check if they have did a mouseout
+ {
+ if (wParam == BUTTON_POLLID) {
+ RECT rc;
+ POINT pt;
+ GetWindowRect(hwndDlg, &rc);
+ GetCursorPos(&pt);
+ if (!PtInRect(&rc, pt)) {
+ // mouse must be gone, trigger mouse leave
+ PostMessage(hwndDlg, WM_MOUSELEAVE, 0, 0L);
+ KillTimer(hwndDlg, BUTTON_POLLID);
+ }
+ }
+ break;
+ }
+ case WM_ERASEBKGND:
+ return 1;
+ }
+ return DefWindowProc(hwndDlg, msg, wParam, lParam);
+}
diff --git a/plugins/TopToolBar/ClassDiagram1.cd b/plugins/TopToolBar/ClassDiagram1.cd
new file mode 100644
index 0000000000..0519ecba6e
--- /dev/null
+++ b/plugins/TopToolBar/ClassDiagram1.cd
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/plugins/TopToolBar/InternalButtons.c b/plugins/TopToolBar/InternalButtons.c
new file mode 100644
index 0000000000..320e8e1d59
--- /dev/null
+++ b/plugins/TopToolBar/InternalButtons.c
@@ -0,0 +1,436 @@
+
+#include "common.h"
+#pragma hdrstop
+
+#define TTBI_GROUPSHOWHIDE "TTBInternal/GroupShowHide"
+#define TTBI_SOUNDSONOFF "TTBInternal/SoundsOnOFF"
+#define TTBI_OPTIONSBUTT "TTBInternal/OptionsBUTT"
+#define TTBI_MAINMENUBUTT "TTBInternal/MainMenuBUTT"
+#define TTBI_MINIMIZEBUTT "TTBInternal/MinimizeBUTT"
+#define TTBI_FINDADDBUTT "TTBInternal/FindAddBUTT"
+
+int LoadInternalButtons();
+int UnLoadInternalButtons();
+extern HINSTANCE hInst;
+
+HANDLE hSettingChangedHook;
+
+static HBITMAP OnlineUp,OnlineDn,GroupsUp,GroupsDn,SoundsUp;
+static HBITMAP SoundsDn,hbOptUp,hbOptDn,testsearch;
+static HBITMAP MainMenuUp,MainMenuDn;
+static HBITMAP MinimizeUp,MinimizeDn;
+static HBITMAP FindUserUp,FindUserDn;
+
+static int ShowOnline,ShowGroups,SoundsEnabled;
+static HANDLE hOnlineBut,hGroupBut,hSoundsBut,hOptionsBut,hMainMenuBut;
+static HANDLE hMinimizeBut;
+static HANDLE hFindUsers;
+
+static HANDLE OnSettingChg;
+
+static HWND hwndContactTree;
+
+int OnSettingChanging(WPARAM wParam,LPARAM lParam)
+{
+ if (wParam!=0){return(0);};
+ {
+ DBCONTACTWRITESETTING *dbcws=(DBCONTACTWRITESETTING *)lParam;
+ if (dbcws==NULL){return(0);};
+
+ if (!strcmp(dbcws->szModule,"CList"))
+ {
+
+ if (!strcmp(dbcws->szSetting,"HideOffline"))
+ {
+ int val=dbcws->value.bVal;
+
+ //OutputDebugStr("==>TopToolBar HideOffline set it\r\n");
+
+ CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hOnlineBut,(LPARAM)(val)?TTBST_PUSHED:TTBST_RELEASED);
+
+ CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hOnlineBut),
+ (LPARAM)((!val)?Translate("Hide Offline Users"):Translate("Show All Users")));
+
+ return(0);
+ };
+
+ if (!strcmp(dbcws->szSetting,"UseGroups"))
+ {
+ int val=dbcws->value.bVal;
+ //int val=GetWindowLong(hwndContactTree,GWL_STYLE)&CLS_USEGROUPS;
+
+ CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hGroupBut,(LPARAM)((val)?TTBST_PUSHED:TTBST_RELEASED));
+
+ return(0);
+ };
+ };
+ if (!strcmp(dbcws->szModule,"Skin"))
+ {
+ if (!strcmp(dbcws->szSetting,"UseSound"))
+ {
+ int val=dbcws->value.bVal;
+
+ CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hSoundsBut,(LPARAM)(val)?TTBST_PUSHED:TTBST_RELEASED);
+
+ return(0);
+ };
+
+ };
+ }
+ return(0);
+};
+INT_PTR TTBInternalFindAddButt(WPARAM wParam,LPARAM lParam)
+{
+ //Sleep(100);
+
+ 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);
+};
+
+INT_PTR TTBInternalMainMenuButt(WPARAM wParam,LPARAM lParam)
+{
+ POINT pt;
+ //CallService("Options/OptionsCommand",0,0);
+ HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0);
+// hMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
+
+ 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);
+};
+INT_PTR TTBInternalGroupShowHide(WPARAM wParam,LPARAM lParam)
+{
+ int newVal=!(GetWindowLong(hwndContactTree,GWL_STYLE)&CLS_USEGROUPS);
+ DBWriteContactSettingByte(NULL,"CList","UseGroups",(BYTE)newVal);
+ SendMessage(hwndContactTree,CLM_SETUSEGROUPS,newVal,0);
+
+ /*
+ CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hGroupBut),
+ (!newVal)?Translate("Show Groups"):Translate("Hide Groups"));
+ */
+ return(0);
+};
+//DBGetContactSettingByte(NULL,"Skin","UseSound",1)
+
+INT_PTR TTBInternalSoundsOnOff(WPARAM wParam,LPARAM lParam)
+{
+ int newVal=!(DBGetContactSettingByte(NULL,"Skin","UseSound",1));
+ DBWriteContactSettingByte(NULL,"Skin","UseSound",(BYTE)newVal);
+ CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hSoundsBut),
+ (LPARAM)((newVal)?Translate("Disable Sounds"):Translate("Enable Sounds")));
+ return(0);
+};
+int UnLoadInternalButtons()
+{
+ if (hSettingChangedHook){UnhookEvent(hSettingChangedHook);};
+ return(0);
+};
+
+boolean framesexists=FALSE;
+int windhandle;
+
+LRESULT CALLBACK TestProczzz(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_CREATE:
+ SetTimer(hwnd,0,100,0);
+ return 0;
+ case WM_TIMER:
+ InvalidateRect(hwnd,NULL,TRUE);
+ RedrawWindow(hwnd,NULL,NULL,0);
+ break;
+ case WM_PAINT:
+ {
+ PAINTSTRUCT lp;
+ HDC hdc;
+ hdc=BeginPaint(hwnd,&lp);
+ if (hdc)
+ {
+ char buf[255];
+ wsprintf((LPSTR)&buf,"%d",GetTickCount());
+ TextOut(hdc,4,4,(LPCTSTR)&buf,strlen(buf));
+ EndPaint(hwnd,&lp);
+ }
+ return(0);
+ }
+
+ }
+
+
+ return(DefWindowProc(hwnd, msg, wParam, lParam));
+};
+
+boolean first=TRUE;
+char pluginname[]="SimpleClassName";
+
+INT_PTR test(WPARAM wParam,LPARAM lParam)
+{
+if (first)
+{
+ WNDCLASS wndclass;
+ int r;
+
+ wndclass.style = 0;
+ wndclass.lpfnWndProc = TestProczzz;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hInst;
+ wndclass.hIcon = NULL;
+ wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);//NULL;//(HBRUSH)(COLOR_3DFACE+1);
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = pluginname;
+ r=RegisterClass(&wndclass);
+ first=FALSE;
+};
+
+if (framesexists)
+{
+ CallService(MS_CLIST_FRAMES_REMOVEFRAME,(WPARAM)windhandle,0);
+ windhandle=0;
+ framesexists=FALSE;
+}else
+{
+ CLISTFrame Frame;
+ //int font;
+
+ HWND pluginwind;
+ pluginwind=CreateWindow(pluginname,pluginname,
+ WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN,
+ 0,0,0,0,(HWND)CallService(MS_CLUI_GETHWND,0,0),NULL,hInst,NULL);
+
+ //font=SendMessage(parent,WM_GETFONT,0,0);
+ //SendMessage(pluginwind,WM_SETFONT,font,0);
+
+ //
+ memset(&Frame,0,sizeof(Frame));
+ Frame.name=(char *)malloc(255);
+ memset(Frame.name,0,255);
+ memcpy(Frame.name,pluginname,sizeof(pluginname));
+ Frame.cbSize=sizeof(Frame);
+ Frame.hWnd=pluginwind;
+ Frame.align=alTop;
+ Frame.Flags=F_VISIBLE;
+ Frame.height=18;
+
+ windhandle=CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,0);
+ framesexists=TRUE;
+ //free(Frame.name);
+};
+return(0);
+};
+
+int LoadInternalButtons(HWND hwnd)
+{
+ TTBButtonV2 ttb;
+
+ hwndContactTree=hwnd;
+ hSettingChangedHook=0;
+ CreateServiceFunction(TTBI_GROUPSHOWHIDE,TTBInternalGroupShowHide);
+ CreateServiceFunction(TTBI_SOUNDSONOFF,TTBInternalSoundsOnOff);
+
+ CreateServiceFunction(TTBI_OPTIONSBUTT,TTBInternalOptionsButt);
+ CreateServiceFunction(TTBI_MAINMENUBUTT,TTBInternalMainMenuButt);
+
+ CreateServiceFunction(TTBI_MINIMIZEBUTT,TTBInternalMinimizeButt);
+ CreateServiceFunction(TTBI_FINDADDBUTT,TTBInternalFindAddButt);
+
+ CreateServiceFunction("TEST1",test);
+
+
+ //ShowOnline=(GetWindowLong(hwndContactTree,GWL_STYLE)&CLS_HIDEOFFLINE);
+ ShowOnline=DBGetContactSettingByte(NULL,"CList","HideOffline",0);
+ //ShowGroups=(GetWindowLong(hwndContactTree,GWL_STYLE)&CLS_USEGROUPS);
+ ShowGroups=DBGetContactSettingByte(NULL,"CList","UseGroups",2);
+ SoundsEnabled=DBGetContactSettingByte(NULL,"Skin","UseSound",1);
+
+/*
+ OnlineDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_ONLINEDN));
+ OnlineUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_ONLINEUP));
+
+ hbOptUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_CPANELUP));
+ hbOptDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_CPANELDN));
+
+ MainMenuUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_MENUUP));
+ MainMenuDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_MENUDN));
+ //MainMenuDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_SEP));
+
+ MinimizeUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_MINIMIZEUP));
+ MinimizeDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_MINIMIZEDN));
+
+ FindUserUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_FINDUSERUP));
+ FindUserDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_FINDUSERDN));
+
+
+ //OnlineDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_TESTBITMAP));
+ //OnlineUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_TESTBITMAP));
+// testsearch=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_SEARCHTEST));
+
+ GroupsDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_GROUPDN));
+ GroupsUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_GROUPUP));
+ SoundsDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_SOUNDSDN));
+ SoundsUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_SOUNDSUP));
+*/
+ //hbOptions=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_OPTIONS));
+
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ //ttb.hbBitmapDown=OnlineDn;
+ //ttb.hbBitmapUp=OnlineUp;
+ ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_SHOWONLINEUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+ ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_SHOWONLINEDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+
+
+
+ ttb.dwFlags=(ShowOnline?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
+ ttb.pszServiceDown=MS_CLIST_SETHIDEOFFLINE;
+ ttb.pszServiceUp=MS_CLIST_SETHIDEOFFLINE;
+ //ttb.lParam=0;
+ ttb.wParamUp=-1;
+ ttb.wParamDown=-1;
+ ttb.name="Show only Online Users";
+ hOnlineBut=(HANDLE)TTBAddButton(&ttb,0);
+
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ //ttb.hbBitmapDown=GroupsDn;
+ //ttb.hbBitmapUp=GroupsUp;
+
+ ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_GROUPSUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+ ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_GROUPSDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+
+ ttb.dwFlags=(ShowGroups?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
+ ttb.pszServiceDown=TTBI_GROUPSHOWHIDE;
+ ttb.pszServiceUp=TTBI_GROUPSHOWHIDE;
+ ttb.name="Groups On/Off";
+ hGroupBut=(HANDLE)TTBAddButton(&ttb,0);
+
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ //ttb.hbBitmapDown=SoundsDn;
+ //ttb.hbBitmapUp=SoundsUp;
+ ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_SOUNDUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+ ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_SOUNDDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+
+ ttb.dwFlags=(SoundsEnabled?TTBBF_PUSHED:0)|TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
+ ttb.pszServiceDown=TTBI_SOUNDSONOFF;
+ ttb.pszServiceUp=TTBI_SOUNDSONOFF;
+ ttb.name="Sounds Enable/Disable";
+ hSoundsBut=(HANDLE)TTBAddButton(&ttb,0);
+/*
+ memset(&ttb,0,sizeof(ttb));
+ ttb.hbBitmapDown=hbOptions;
+ ttb.hbBitmapUp=hbOptions;
+ ttb.dwFlags=TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP|TTBBF_DRAWBORDER;
+ ttb.pszServiceDown="Options/OptionsCommand";
+ ttb.pszServiceUp="Options/OptionsCommand";
+ ttb.lParam=0;
+ ttb.wParam=0;
+// hOptionsBut=TTBAddButton(&ttb,0);
+*/
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ //ttb.hbBitmapDown=hbOptDn;
+ //ttb.hbBitmapUp=hbOptUp;
+ ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_OPTIONSUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+ ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_OPTIONSDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+
+ ttb.dwFlags=TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
+ ttb.pszServiceDown=TTBI_OPTIONSBUTT;
+ ttb.pszServiceUp=TTBI_OPTIONSBUTT;
+ ttb.name="Show Options Page";
+ hOptionsBut=(HANDLE)TTBAddButton(&ttb,0);
+
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ //ttb.hbBitmapDown=MinimizeDn;
+ //ttb.hbBitmapUp=MinimizeUp;
+ ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_MINIMIZEUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+ ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_MINIMIZEDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+
+ ttb.dwFlags=TTBBF_VISIBLE;
+ ttb.pszServiceDown=TTBI_MINIMIZEBUTT;
+ ttb.pszServiceUp=TTBI_MINIMIZEBUTT;
+ ttb.name="Minimize Button";
+ hMinimizeBut=(HANDLE)TTBAddButton(&ttb,0);
+
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ //ttb.hbBitmapDown=FindUserDn;
+ //ttb.hbBitmapUp=FindUserUp;
+ ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_FINDADDUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+ ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_FINDADDDN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+
+ ttb.dwFlags=TTBBF_VISIBLE;
+ ttb.pszServiceDown=TTBI_FINDADDBUTT;
+ ttb.pszServiceUp=TTBI_FINDADDBUTT;
+ ttb.name="Find/Add Contacts";
+ hFindUsers=(HANDLE)TTBAddButton(&ttb,0);
+
+
+
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ //ttb.hbBitmapUp=MainMenuUp;
+ //ttb.hbBitmapDown=MainMenuDn;
+ ttb.hIconUp=LoadImage(hInst,MAKEINTRESOURCE(IDI_MIRANDAUP),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+ ttb.hIconDn=LoadImage(hInst,MAKEINTRESOURCE(IDI_MIRANDADN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+
+ ttb.dwFlags=TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
+ ttb.pszServiceDown=TTBI_MAINMENUBUTT;
+ ttb.pszServiceUp=TTBI_MAINMENUBUTT;
+ ttb.name="Show Main Menu";
+ hMainMenuBut=(HANDLE)TTBAddButton(&ttb,0);
+
+
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ //ttb.hbBitmapUp=MainMenuUp;
+ //ttb.hbBitmapDown=MainMenuDn;
+ ttb.dwFlags=TTBBF_VISIBLE;
+ ttb.pszServiceDown="TEST1";
+ ttb.pszServiceUp="TEST1";
+ ttb.name="Test";
+ //TTBAddButton(&ttb,0);
+
+ CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hOnlineBut),
+ (LPARAM)((ShowOnline)?Translate("Hide Offline Users"):Translate("Show All Users")));
+
+ CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hGroupBut),
+ (LPARAM)((ShowGroups)?Translate("Hide Groups"):Translate("Show Groups")));
+
+ CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hSoundsBut),
+ (LPARAM)((SoundsEnabled)?Translate("Disable Sounds"):Translate("Enable Sounds")));
+
+ CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hOptionsBut),
+ (LPARAM)Translate("Show Options"));
+
+ //OutputDebugStr("==>TopToolBar setted Hook for ME_DB_CONTACT_SETTINGCHANGED\r\n");
+ //hSettingChangedHook=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,OnSettingChanging);
+ //OutputDebugStr("==>TopToolBar setted Hook for ME_DB_CONTACT_SETTINGCHANGED Done\r\n");
+
+ return(0);
+
+}; \ No newline at end of file
diff --git a/plugins/TopToolBar/TopToolBar.sln b/plugins/TopToolBar/TopToolBar.sln
new file mode 100644
index 0000000000..4d6ba7100e
--- /dev/null
+++ b/plugins/TopToolBar/TopToolBar.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TopToolBar", "TopToolBar.vcxproj", "{ECE691D0-BFB3-483B-A699-084269EFCE89}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|Win32.ActiveCfg = Debug|Win32
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|Win32.Build.0 = Debug|Win32
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|x64.ActiveCfg = Debug|x64
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Debug|x64.Build.0 = Debug|x64
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|Win32.ActiveCfg = Release|Win32
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|Win32.Build.0 = Release|Win32
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|x64.ActiveCfg = Release|x64
+ {ECE691D0-BFB3-483B-A699-084269EFCE89}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/plugins/TopToolBar/TopToolBar.vcxproj b/plugins/TopToolBar/TopToolBar.vcxproj
new file mode 100644
index 0000000000..0609a5725d
--- /dev/null
+++ b/plugins/TopToolBar/TopToolBar.vcxproj
@@ -0,0 +1,335 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{ECE691D0-BFB3-483B-A699-084269EFCE89}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>.\Debug/TopToolBar.tlb</TypeLibraryName>
+ <HeaderFileName>
+ </HeaderFileName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0419</Culture>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <BaseAddress>0x1b200000</BaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ <Bscmake>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Bscmake>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TypeLibraryName>.\Debug/TopToolBar.tlb</TypeLibraryName>
+ <HeaderFileName>
+ </HeaderFileName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0419</Culture>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <BaseAddress>0x1b200000</BaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ <Bscmake>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Bscmake>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>.\Release/TopToolBar.tlb</TypeLibraryName>
+ <HeaderFileName>
+ </HeaderFileName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <BaseAddress>0x1b200000</BaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ </Link>
+ <Bscmake>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Bscmake>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TypeLibraryName>.\Release/TopToolBar.tlb</TypeLibraryName>
+ <HeaderFileName>
+ </HeaderFileName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;TOPTOOLBAR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <BaseAddress>0x1b200000</BaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ </Link>
+ <Bscmake>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ </Bscmake>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="button.c">
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile Include="CLCButton.c">
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile Include="InternalButtons.c">
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile Include="launchbt.c">
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile Include="main.c">
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile Include="separators.c">
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ClCompile Include="ttbopt.c">
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="BkgrCfg.h" />
+ <ClInclude Include="common.h" />
+ <ClInclude Include="m_toptoolbar.h" />
+ <ClInclude Include="resource.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="bmp\bitmap1.bmp" />
+ <None Include="bmp\bmp00002.bmp" />
+ <None Include="bmp\borderup.bmp" />
+ <None Include="bmp\borederdn.bmp" />
+ <None Include="bmp\cpaneldn.bmp" />
+ <None Include="bmp\cpanelup.bmp" />
+ <None Include="find.ico" />
+ <None Include="icos\Find_Add Contacts_DN.ico" />
+ <None Include="icos\Find_Add Contacts_UP.ico" />
+ <None Include="bmp\finduser.bmp" />
+ <None Include="bmp\finduserdn.bmp" />
+ <None Include="bmp\groupdn.bmp" />
+ <None Include="icos\Groups On_Off_DN.ico" />
+ <None Include="icos\Groups On_Off_UP.ico" />
+ <None Include="bmp\groupup.bmp" />
+ <None Include="bmp\launch.bmp" />
+ <None Include="bmp\launchdn.bmp" />
+ <None Include="bmp\launchup.bmp" />
+ <None Include="bmp\menudn.bmp" />
+ <None Include="bmp\menuup.bmp" />
+ <None Include="icos\Minimize Button_DN.ico" />
+ <None Include="icos\Minimize Button_UP.ico" />
+ <None Include="bmp\minimize.bmp" />
+ <None Include="bmp\minimizedn.bmp" />
+ <None Include="icos\notick.ico" />
+ <None Include="icos\notick1.ico" />
+ <None Include="bmp\options.bmp" />
+ <None Include="icos\Run.ico" />
+ <None Include="bmp\searchtest.bmp" />
+ <None Include="bmp\sep.bmp" />
+ <None Include="icos\Show Main Menu_DN.ico" />
+ <None Include="icos\Show Main Menu_UP.ico" />
+ <None Include="icos\Show only Online Users_DN.ico" />
+ <None Include="icos\Show only Online Users_UP.ico" />
+ <None Include="icos\Show Options Page_DN.ico" />
+ <None Include="icos\Show Options Page_UP.ico" />
+ <None Include="icos\Sounds Enable_Disable_DN.ico" />
+ <None Include="icos\Sounds Enable_Disable_UP.ico" />
+ <None Include="bmp\soundsdn.bmp" />
+ <None Include="bmp\soundsup.bmp" />
+ <None Include="bmp\test.bmp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="main.rc">
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/plugins/TopToolBar/TopToolBar.vcxproj.filters b/plugins/TopToolBar/TopToolBar.vcxproj.filters
new file mode 100644
index 0000000000..f70b2e4a25
--- /dev/null
+++ b/plugins/TopToolBar/TopToolBar.vcxproj.filters
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{7706e6ca-cf12-4f40-8864-82916b4669c8}</UniqueIdentifier>
+ <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{872b8e16-3822-4f40-8957-4daf9343eb99}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{fbadd592-e14c-4abf-bf9e-5f2b3b808d64}</UniqueIdentifier>
+ <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="button.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="CLCButton.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="InternalButtons.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="launchbt.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="main.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="separators.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="ttbopt.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="BkgrCfg.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="m_toptoolbar.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="bmp\bitmap1.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\bmp00002.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\borderup.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\borederdn.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\cpaneldn.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\cpanelup.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="find.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Find_Add Contacts_DN.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Find_Add Contacts_UP.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\finduser.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\finduserdn.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\groupdn.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Groups On_Off_DN.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Groups On_Off_UP.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\groupup.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\launch.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\launchdn.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\launchup.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\menudn.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\menuup.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Minimize Button_DN.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Minimize Button_UP.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\minimize.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\minimizedn.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\notick.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\notick1.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\options.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Run.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\searchtest.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\sep.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Show Main Menu_DN.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Show Main Menu_UP.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Show only Online Users_DN.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Show only Online Users_UP.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Show Options Page_DN.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Show Options Page_UP.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Sounds Enable_Disable_DN.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="icos\Sounds Enable_Disable_UP.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\soundsdn.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\soundsup.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="bmp\test.bmp">
+ <Filter>Resource Files</Filter>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="main.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/plugins/TopToolBar/_button.c b/plugins/TopToolBar/_button.c
new file mode 100644
index 0000000000..6998efb409
--- /dev/null
+++ b/plugins/TopToolBar/_button.c
@@ -0,0 +1,515 @@
+/*
+Miranda IM
+Copyright (C) 2002 Robert Rainwater
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "common.h"
+
+// TODO:
+// - Support for bitmap buttons (simple call to DrawIconEx())
+
+static LRESULT CALLBACK MButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+typedef struct {
+ HWND hwnd;
+ int stateId; // button state
+ int focus; // has focus (1 or 0)
+ HFONT hFont; // font
+ HICON arrow; // uses down arrow
+ int defbutton; // default button
+ HICON hIcon;
+ HBITMAP hBitmap;
+ int pushBtn;
+ int pbState;
+ HANDLE hThemeButton;
+ HANDLE hThemeToolbar;
+ char cHot;
+ int flatBtn;
+} MButtonCtrl;
+
+
+// External theme methods and properties
+static HMODULE themeAPIHandle = NULL; // handle to uxtheme.dll
+static HANDLE (WINAPI *MyOpenThemeData)(HWND,LPCWSTR);
+static HRESULT (WINAPI *MyCloseThemeData)(HANDLE);
+static BOOL (WINAPI *MyIsThemeBackgroundPartiallyTransparent)(HANDLE,int,int);
+static HRESULT (WINAPI *MyDrawThemeParentBackground)(HWND,HDC,RECT *);
+static HRESULT (WINAPI *MyDrawThemeBackground)(HANDLE,HDC,int,int,const RECT *,const RECT *);
+static HRESULT (WINAPI *MyDrawThemeText)(HANDLE,HDC,int,int,LPCWSTR,int,DWORD,DWORD,const RECT *);
+
+static CRITICAL_SECTION csTips;
+static HWND hwndToolTips = NULL;
+
+int UnloadButtonModule(WPARAM wParam, LPARAM lParam) {
+ DeleteCriticalSection(&csTips);
+ return 0;
+}
+
+int LoadButtonModule(void) {
+ WNDCLASSEX wc;
+
+ ZeroMemory(&wc, sizeof(wc));
+ wc.cbSize = sizeof(wc);
+ wc.lpszClassName = MYMIRANDABUTTONCLASS;
+ wc.lpfnWndProc = MButtonWndProc;
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.cbWndExtra = sizeof(MButtonCtrl*);
+ wc.hbrBackground = 0;
+ wc.style = CS_GLOBALCLASS;
+ RegisterClassEx(&wc);
+ InitializeCriticalSection(&csTips);
+ HookEvent(ME_SYSTEM_SHUTDOWN, UnloadButtonModule);
+ return 0;
+}
+
+// Used for our own cheap TrackMouseEvent
+#define BUTTON_POLLID 100
+#define BUTTON_POLLDELAY 50
+
+#define MGPROC(x) GetProcAddress(themeAPIHandle,x)
+static int ThemeSupport() {
+ if (IsWinVerXPPlus()) {
+ if (!themeAPIHandle) {
+ themeAPIHandle = GetModuleHandle("uxtheme");
+ if (themeAPIHandle) {
+ MyOpenThemeData = (HANDLE (WINAPI *)(HWND,LPCWSTR))MGPROC("OpenThemeData");
+ MyCloseThemeData = (HRESULT (WINAPI *)(HANDLE))MGPROC("CloseThemeData");
+ MyIsThemeBackgroundPartiallyTransparent = (BOOL (WINAPI *)(HANDLE,int,int))MGPROC("IsThemeBackgroundPartiallyTransparent");
+ MyDrawThemeParentBackground = (HRESULT (WINAPI *)(HWND,HDC,RECT *))MGPROC("DrawThemeParentBackground");
+ MyDrawThemeBackground = (HRESULT (WINAPI *)(HANDLE,HDC,int,int,const RECT *,const RECT *))MGPROC("DrawThemeBackground");
+ MyDrawThemeText = (HRESULT (WINAPI *)(HANDLE,HDC,int,int,LPCWSTR,int,DWORD,DWORD,const RECT *))MGPROC("DrawThemeText");
+ }
+ }
+ // Make sure all of these methods are valid (i would hope either all or none work)
+ if (MyOpenThemeData
+ &&MyCloseThemeData
+ &&MyIsThemeBackgroundPartiallyTransparent
+ &&MyDrawThemeParentBackground
+ &&MyDrawThemeBackground
+ &&MyDrawThemeText) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void DestroyTheme(MButtonCtrl *ctl) {
+ if (ThemeSupport()) {
+ if (ctl->hThemeButton) {
+ MyCloseThemeData(ctl->hThemeButton);
+ ctl->hThemeButton = NULL;
+ }
+ if (ctl->hThemeToolbar) {
+ MyCloseThemeData(ctl->hThemeToolbar);
+ ctl->hThemeToolbar = NULL;
+ }
+ }
+}
+
+static void LoadTheme(MButtonCtrl *ctl) {
+ if (ThemeSupport()) {
+ DestroyTheme(ctl);
+ ctl->hThemeButton = MyOpenThemeData(ctl->hwnd,L"BUTTON");
+ ctl->hThemeToolbar = MyOpenThemeData(ctl->hwnd,L"TOOLBAR");
+ }
+}
+
+static TBStateConvert2Flat(int state) {
+ switch(state) {
+ case PBS_NORMAL: return TS_NORMAL;
+ case PBS_HOT: return TS_HOT;
+ case PBS_PRESSED: return TS_PRESSED;
+ case PBS_DISABLED: return TS_DISABLED;
+ case PBS_DEFAULTED: return TS_NORMAL;
+ }
+ return TS_NORMAL;
+}
+
+static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) {
+ if (hdcPaint) {
+ RECT rcClient;
+ GetClientRect(ctl->hwnd, &rcClient);
+
+ // If its a push button, check to see if it should stay pressed
+ if (ctl->pushBtn && ctl->pbState) ctl->stateId = PBS_PRESSED;
+
+ // Draw the flat button
+ if (ctl->flatBtn) {
+ if (ctl->hThemeToolbar) {
+ int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId==PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED;
+ if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) {
+ MyDrawThemeParentBackground(ctl->hwnd, hdcPaint, &rcClient);
+ }
+ MyDrawThemeBackground(ctl->hThemeToolbar, hdcPaint, TP_BUTTON, TBStateConvert2Flat(state), &rcClient, &rcClient);
+ }
+ else {
+ HBRUSH hbr;
+
+ if (ctl->stateId==PBS_PRESSED||ctl->stateId==PBS_HOT)
+ hbr = GetSysColorBrush(COLOR_3DLIGHT);
+ else {
+ HDC dc;
+ HWND hwndParent;
+
+ hwndParent = GetParent(ctl->hwnd);
+ dc=GetDC(hwndParent);
+ hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)dc, (LPARAM)hwndParent);
+ ReleaseDC(hwndParent,dc);
+ }
+ if (hbr) {
+ FillRect(hdcPaint, &rcClient, hbr);
+ DeleteObject(hbr);
+ }
+ if (ctl->stateId==PBS_HOT||ctl->focus) {
+ if (ctl->pbState)
+ DrawEdge(hdcPaint,&rcClient, EDGE_ETCHED,BF_RECT|BF_SOFT);
+ else DrawEdge(hdcPaint,&rcClient, BDR_RAISEDOUTER,BF_RECT|BF_SOFT|BF_FLAT);
+ }
+ else if (ctl->stateId==PBS_PRESSED)
+ DrawEdge(hdcPaint, &rcClient, BDR_SUNKENOUTER,BF_RECT|BF_SOFT);
+ }
+ }
+ else {
+ // Draw background/border
+ if (ctl->hThemeButton) {
+ int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId==PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED;
+ if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) {
+ MyDrawThemeParentBackground(ctl->hwnd, hdcPaint, &rcClient);
+ }
+ MyDrawThemeBackground(ctl->hThemeButton, hdcPaint, BP_PUSHBUTTON, state, &rcClient, &rcClient);
+ }
+ else {
+ UINT uState = DFCS_BUTTONPUSH|((ctl->stateId==PBS_HOT)?DFCS_HOT:0)|((ctl->stateId == PBS_PRESSED)?DFCS_PUSHED:0);
+ if (ctl->defbutton&&ctl->stateId==PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON;
+ DrawFrameControl(hdcPaint, &rcClient, DFC_BUTTON, uState);
+ }
+
+ // Draw focus rectangle if button has focus
+ if (ctl->focus) {
+ RECT focusRect = rcClient;
+ InflateRect(&focusRect, -3, -3);
+ DrawFocusRect(hdcPaint, &focusRect);
+ }
+ }
+
+ // If we have an icon or a bitmap, ignore text and only draw the image on the button
+ if (ctl->hIcon) {
+ int ix = (rcClient.right-rcClient.left)/2 - (GetSystemMetrics(SM_CXSMICON)/2);
+ int iy = (rcClient.bottom-rcClient.top)/2 - (GetSystemMetrics(SM_CYSMICON)/2);
+ if (ctl->stateId == PBS_PRESSED) {
+ ix++;
+ iy++;
+ }
+ DrawState(hdcPaint,NULL,NULL,(LPARAM)ctl->hIcon,0,ix,iy,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),IsWindowEnabled(ctl->hwnd)?DST_ICON:DST_ICON|DSS_DISABLED);
+ }
+ else if (ctl->hBitmap) {
+ BITMAP bminfo;
+ int ix,iy;
+
+ GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo);
+ ix = (rcClient.right-rcClient.left)/2 - (bminfo.bmWidth/2);
+ iy = (rcClient.bottom-rcClient.top)/2 - (bminfo.bmHeight/2);
+ if (ctl->stateId == PBS_PRESSED) {
+ ix++;
+ iy++;
+ }
+ DrawState(hdcPaint,NULL,NULL,(LPARAM)ctl->hBitmap,0,ix,iy,bminfo.bmWidth,bminfo.bmHeight,IsWindowEnabled(ctl->hwnd)?DST_BITMAP:DST_BITMAP|DSS_DISABLED);
+ }
+ else if (GetWindowTextLength(ctl->hwnd)) {
+ // Draw the text and optinally the arrow
+ char szText[MAX_PATH];
+ SIZE sz;
+ RECT rcText;
+
+ CopyRect(&rcText, &rcClient);
+ GetWindowText(ctl->hwnd, szText, sizeof(szText));
+ SetBkMode(hdcPaint, TRANSPARENT);
+ SelectObject(hdcPaint, ctl->hFont);
+ // XP w/themes doesn't used the glossy disabled text. Is it always using COLOR_GRAYTEXT? Seems so.
+ SetTextColor(hdcPaint, IsWindowEnabled(ctl->hwnd)||!ctl->hThemeButton?GetSysColor(COLOR_BTNTEXT):GetSysColor(COLOR_GRAYTEXT));
+ GetTextExtentPoint32(hdcPaint, szText, lstrlen(szText), &sz);
+ if (ctl->cHot) {
+ SIZE szHot;
+
+ GetTextExtentPoint32(hdcPaint, "&", 1, &szHot);
+ sz.cx -= szHot.cx;
+ }
+ if (ctl->arrow) {
+ DrawState(hdcPaint,NULL,NULL,(LPARAM)ctl->arrow,0,rcClient.right-rcClient.left-5-GetSystemMetrics(SM_CXSMICON)+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),(rcClient.bottom-rcClient.top)/2-GetSystemMetrics(SM_CYSMICON)/2+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),IsWindowEnabled(ctl->hwnd)?DST_ICON:DST_ICON|DSS_DISABLED);
+ }
+ SelectObject(hdcPaint, ctl->hFont);
+ DrawState(hdcPaint,NULL,NULL,(LPARAM)szText,0,(rcText.right-rcText.left-sz.cx)/2+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),ctl->hThemeButton?(rcText.bottom-rcText.top-sz.cy)/2:(rcText.bottom-rcText.top-sz.cy)/2-(ctl->stateId==PBS_PRESSED?0:1),sz.cx,sz.cy,IsWindowEnabled(ctl->hwnd)||ctl->hThemeButton?DST_PREFIXTEXT|DSS_NORMAL:DST_PREFIXTEXT|DSS_DISABLED);
+ }
+ }
+}
+
+static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+ MButtonCtrl* bct = (MButtonCtrl *)GetWindowLong(hwndDlg, 0);
+ switch(msg) {
+ case WM_NCCREATE:
+ {
+ SetWindowLong(hwndDlg, GWL_STYLE, GetWindowLong(hwndDlg, GWL_STYLE)|BS_OWNERDRAW);
+ bct = malloc(sizeof(MButtonCtrl));
+ if (bct==NULL) return FALSE;
+ bct->hwnd = hwndDlg;
+ bct->stateId = PBS_NORMAL;
+ bct->focus = 0;
+ bct->hFont = GetStockObject(DEFAULT_GUI_FONT);
+ bct->arrow = NULL;
+ bct->defbutton = 0;
+ bct->hIcon = NULL;
+ bct->hBitmap = NULL;
+ bct->pushBtn = 0;
+ bct->pbState = 0;
+ bct->hThemeButton = NULL;
+ bct->hThemeToolbar = NULL;
+ bct->cHot = 0;
+ bct->flatBtn = 0;
+ LoadTheme(bct);
+ SetWindowLong(hwndDlg, 0, (LONG)bct);
+ if (((CREATESTRUCT *)lParam)->lpszName) SetWindowText(hwndDlg, ((CREATESTRUCT *)lParam)->lpszName);
+ return TRUE;
+ }
+ case WM_DESTROY:
+ {
+ if (bct) {
+ EnterCriticalSection(&csTips);
+ if (hwndToolTips) {
+ TOOLINFO ti;
+
+ ZeroMemory(&ti, sizeof(ti));
+ ti.cbSize = sizeof(ti);
+ ti.uFlags = TTF_IDISHWND;
+ ti.hwnd = bct->hwnd;
+ ti.uId = (UINT)bct->hwnd;
+ if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) {
+ SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti);
+ }
+ if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM)&ti)==0) {
+ DestroyWindow(hwndToolTips);
+ hwndToolTips = NULL;
+ }
+ }
+ LeaveCriticalSection(&csTips);
+ DestroyTheme(bct);
+ free(bct);
+ }
+ SetWindowLong(hwndDlg,0,(LONG)NULL);
+ break; // DONT! fall thru
+ }
+ case WM_SETTEXT:
+ {
+ bct->cHot = 0;
+ if ((char*)lParam) {
+ char *tmp = (char*)lParam;
+ while (*tmp) {
+ if (*tmp=='&' && *(tmp+1)) {
+ bct->cHot = tolower(*(tmp+1));
+ break;
+ }
+ tmp++;
+ }
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ }
+ case WM_SYSKEYUP:
+ if (bct->stateId!=PBS_DISABLED && bct->cHot && bct->cHot == tolower((int)wParam)) {
+ if (bct->pushBtn) {
+ if (bct->pbState) bct->pbState = 0;
+ else bct->pbState = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
+ return 0;
+ }
+ break;
+ case WM_THEMECHANGED: {
+ // themed changed, reload theme object
+ LoadTheme(bct);
+ InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it
+ break;
+ }
+ case WM_SETFONT: // remember the font so we can use it later
+ {
+ bct->hFont = (HFONT)wParam; // maybe we should redraw?
+ break;
+ }
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ HDC hdcPaint;
+
+ hdcPaint = BeginPaint(hwndDlg, &ps);
+ if (hdcPaint) {
+ PaintWorker(bct, hdcPaint);
+ EndPaint(hwndDlg, &ps);
+ }
+ break;
+ }
+ case BM_SETIMAGE:
+ if (wParam == IMAGE_ICON) {
+ bct->hIcon = (HICON)lParam;
+ bct->hBitmap = NULL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ else if (wParam == IMAGE_BITMAP) {
+ bct->hBitmap = (HBITMAP)lParam;
+ bct->hIcon = NULL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ case BM_SETCHECK:
+ if (!bct->pushBtn) break;
+ if (wParam == BST_CHECKED) {
+ bct->pbState = 1;
+ bct->stateId = PBS_PRESSED;
+ }
+ else if (wParam == BST_UNCHECKED) {
+ bct->pbState = 0;
+ bct->stateId = PBS_NORMAL;
+ }
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BM_GETCHECK:
+ if (bct->pushBtn) {
+ return bct->pbState?BST_CHECKED:BST_UNCHECKED;
+ }
+ return 0;
+ case BUTTONSETARROW: // turn arrow on/off
+ if (wParam) {
+ //if (!bct->arrow)
+ //bct->arrow = (HICON)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DOWNARROW),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0);
+ }
+ else {
+ if (bct->arrow) {
+ DestroyIcon(bct->arrow);
+ bct->arrow = NULL;
+ }
+ }
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONSETDEFAULT:
+ bct->defbutton = wParam?1:0;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONSETASPUSHBTN:
+ bct->pushBtn = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONSETASFLATBTN:
+ bct->flatBtn = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONADDTOOLTIP:
+ {
+ TOOLINFO ti;
+
+ if (!(char*)wParam) break;
+ EnterCriticalSection(&csTips);
+ if (!hwndToolTips) {
+ hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
+ }
+ ZeroMemory(&ti, sizeof(ti));
+ ti.cbSize = sizeof(ti);
+ ti.uFlags = TTF_IDISHWND;
+ ti.hwnd = bct->hwnd;
+ ti.uId = (UINT)bct->hwnd;
+ if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) {
+ SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti);
+ }
+ ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS;
+ ti.uId = (UINT)bct->hwnd;
+ ti.lpszText=(char*)wParam;
+ SendMessage(hwndToolTips,TTM_ADDTOOL,0,(LPARAM)&ti);
+ LeaveCriticalSection(&csTips);
+ break;
+ }
+ case WM_SETFOCUS: // set keybord focus and redraw
+ bct->focus = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case WM_KILLFOCUS: // kill focus and redraw
+ bct->focus = 0;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case WM_WINDOWPOSCHANGED:
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case WM_ENABLE: // windows tells us to enable/disable
+ {
+ bct->stateId = wParam?PBS_NORMAL:PBS_DISABLED;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ }
+ case WM_MOUSELEAVE: // faked by the WM_TIMER
+ {
+ if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled
+ bct->stateId = PBS_NORMAL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ }
+ case WM_LBUTTONDOWN:
+ {
+ if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled
+ bct->stateId = PBS_PRESSED;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ }
+ case WM_LBUTTONUP:
+ {
+ if (bct->pushBtn) {
+ if (bct->pbState) bct->pbState = 0;
+ else bct->pbState = 1;
+ }
+ if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled
+ if (msg==WM_LBUTTONUP) bct->stateId = PBS_HOT;
+ else bct->stateId = PBS_NORMAL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ // Tell your daddy you got clicked.
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
+ break;
+ }
+ case WM_MOUSEMOVE:
+ if (bct->stateId == PBS_NORMAL) {
+ bct->stateId = PBS_HOT;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ // Call timer, used to start cheesy TrackMouseEvent faker
+ SetTimer(hwndDlg,BUTTON_POLLID,BUTTON_POLLDELAY,NULL);
+ break;
+ case WM_TIMER: // use a timer to check if they have did a mouseout
+ {
+ if (wParam==BUTTON_POLLID) {
+ RECT rc;
+ POINT pt;
+ GetWindowRect(hwndDlg,&rc);
+ GetCursorPos(&pt);
+ if(!PtInRect(&rc,pt)) { // mouse must be gone, trigger mouse leave
+ PostMessage(hwndDlg,WM_MOUSELEAVE,0,0L);
+ KillTimer(hwndDlg,BUTTON_POLLID);
+ }
+ }
+ break;
+ }
+ case WM_ERASEBKGND:
+ return 1;
+ }
+ return DefWindowProc(hwndDlg, msg, wParam, lParam);
+}
diff --git a/plugins/TopToolBar/afxres.h b/plugins/TopToolBar/afxres.h
new file mode 100644
index 0000000000..4b9ab506f5
--- /dev/null
+++ b/plugins/TopToolBar/afxres.h
@@ -0,0 +1,2 @@
+#include <windows.h>
+#include <winres.h>
diff --git a/plugins/TopToolBar/bmp/bitmap1.bmp b/plugins/TopToolBar/bmp/bitmap1.bmp
new file mode 100644
index 0000000000..573b7d6186
--- /dev/null
+++ b/plugins/TopToolBar/bmp/bitmap1.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/bmp00001.bmp b/plugins/TopToolBar/bmp/bmp00001.bmp
new file mode 100644
index 0000000000..7c97999188
--- /dev/null
+++ b/plugins/TopToolBar/bmp/bmp00001.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/bmp00002.bmp b/plugins/TopToolBar/bmp/bmp00002.bmp
new file mode 100644
index 0000000000..6e8e840620
--- /dev/null
+++ b/plugins/TopToolBar/bmp/bmp00002.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/borderup.bmp b/plugins/TopToolBar/bmp/borderup.bmp
new file mode 100644
index 0000000000..2d7fd71299
--- /dev/null
+++ b/plugins/TopToolBar/bmp/borderup.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/borederdn.bmp b/plugins/TopToolBar/bmp/borederdn.bmp
new file mode 100644
index 0000000000..53809acff3
--- /dev/null
+++ b/plugins/TopToolBar/bmp/borederdn.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/cpaneldn.bmp b/plugins/TopToolBar/bmp/cpaneldn.bmp
new file mode 100644
index 0000000000..2f4e2a95b5
--- /dev/null
+++ b/plugins/TopToolBar/bmp/cpaneldn.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/cpanelup.bmp b/plugins/TopToolBar/bmp/cpanelup.bmp
new file mode 100644
index 0000000000..fc3531facd
--- /dev/null
+++ b/plugins/TopToolBar/bmp/cpanelup.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/findusedn.bmp b/plugins/TopToolBar/bmp/findusedn.bmp
new file mode 100644
index 0000000000..f21e56fb95
--- /dev/null
+++ b/plugins/TopToolBar/bmp/findusedn.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/finduser.bmp b/plugins/TopToolBar/bmp/finduser.bmp
new file mode 100644
index 0000000000..e6a884651b
--- /dev/null
+++ b/plugins/TopToolBar/bmp/finduser.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/finduserdn.bmp b/plugins/TopToolBar/bmp/finduserdn.bmp
new file mode 100644
index 0000000000..668a92c4b5
--- /dev/null
+++ b/plugins/TopToolBar/bmp/finduserdn.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/groupdn.bmp b/plugins/TopToolBar/bmp/groupdn.bmp
new file mode 100644
index 0000000000..9a106b15ee
--- /dev/null
+++ b/plugins/TopToolBar/bmp/groupdn.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/groupup.bmp b/plugins/TopToolBar/bmp/groupup.bmp
new file mode 100644
index 0000000000..7bc71b6764
--- /dev/null
+++ b/plugins/TopToolBar/bmp/groupup.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/launch.bmp b/plugins/TopToolBar/bmp/launch.bmp
new file mode 100644
index 0000000000..326c0d31c6
--- /dev/null
+++ b/plugins/TopToolBar/bmp/launch.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/launchdn.bmp b/plugins/TopToolBar/bmp/launchdn.bmp
new file mode 100644
index 0000000000..0e72934853
--- /dev/null
+++ b/plugins/TopToolBar/bmp/launchdn.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/launchup.bmp b/plugins/TopToolBar/bmp/launchup.bmp
new file mode 100644
index 0000000000..22584a7e3b
--- /dev/null
+++ b/plugins/TopToolBar/bmp/launchup.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/menudn.bmp b/plugins/TopToolBar/bmp/menudn.bmp
new file mode 100644
index 0000000000..ad93aff878
--- /dev/null
+++ b/plugins/TopToolBar/bmp/menudn.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/menuup.bmp b/plugins/TopToolBar/bmp/menuup.bmp
new file mode 100644
index 0000000000..a3a902ae6e
--- /dev/null
+++ b/plugins/TopToolBar/bmp/menuup.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/minimize.bmp b/plugins/TopToolBar/bmp/minimize.bmp
new file mode 100644
index 0000000000..4749fa9369
--- /dev/null
+++ b/plugins/TopToolBar/bmp/minimize.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/minimizedn.bmp b/plugins/TopToolBar/bmp/minimizedn.bmp
new file mode 100644
index 0000000000..f8470a3d6a
--- /dev/null
+++ b/plugins/TopToolBar/bmp/minimizedn.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/options.bmp b/plugins/TopToolBar/bmp/options.bmp
new file mode 100644
index 0000000000..945be884f4
--- /dev/null
+++ b/plugins/TopToolBar/bmp/options.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/searchtest.bmp b/plugins/TopToolBar/bmp/searchtest.bmp
new file mode 100644
index 0000000000..2b2fda1042
--- /dev/null
+++ b/plugins/TopToolBar/bmp/searchtest.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/sep.bmp b/plugins/TopToolBar/bmp/sep.bmp
new file mode 100644
index 0000000000..1665285275
--- /dev/null
+++ b/plugins/TopToolBar/bmp/sep.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/separator.bmp b/plugins/TopToolBar/bmp/separator.bmp
new file mode 100644
index 0000000000..fa4a4449f0
--- /dev/null
+++ b/plugins/TopToolBar/bmp/separator.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/soundsdn.bmp b/plugins/TopToolBar/bmp/soundsdn.bmp
new file mode 100644
index 0000000000..224e299691
--- /dev/null
+++ b/plugins/TopToolBar/bmp/soundsdn.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/soundsup.bmp b/plugins/TopToolBar/bmp/soundsup.bmp
new file mode 100644
index 0000000000..c11e7521fe
--- /dev/null
+++ b/plugins/TopToolBar/bmp/soundsup.bmp
Binary files differ
diff --git a/plugins/TopToolBar/bmp/test.bmp b/plugins/TopToolBar/bmp/test.bmp
new file mode 100644
index 0000000000..b3b4252fef
--- /dev/null
+++ b/plugins/TopToolBar/bmp/test.bmp
Binary files differ
diff --git a/plugins/TopToolBar/button.c b/plugins/TopToolBar/button.c
new file mode 100644
index 0000000000..a8ed3d0270
--- /dev/null
+++ b/plugins/TopToolBar/button.c
@@ -0,0 +1,541 @@
+/*
+Miranda IM
+Copyright (C) 2002 Robert Rainwater
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "common.h"
+
+// TODO:
+// - Support for bitmap buttons (simple call to DrawIconEx())
+
+static LRESULT CALLBACK MButtonWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+typedef struct {
+ HWND hwnd;
+ int stateId; // button state
+ int focus; // has focus (1 or 0)
+ HFONT hFont; // font
+ HICON arrow; // uses down arrow
+ int defbutton; // default button
+ HICON hIcon;
+ HBITMAP hBitmap;
+ int pushBtn;
+ int pbState;
+ HANDLE hThemeButton;
+ HANDLE hThemeToolbar;
+ char cHot;
+ int flatBtn;
+} MButtonCtrl;
+
+
+// External theme methods and properties
+static HMODULE themeAPIHandle = NULL; // handle to uxtheme.dll
+static HANDLE (WINAPI *MyOpenThemeData)(HWND,LPCWSTR);
+static HRESULT (WINAPI *MyCloseThemeData)(HANDLE);
+static BOOL (WINAPI *MyIsThemeBackgroundPartiallyTransparent)(HANDLE,int,int);
+static HRESULT (WINAPI *MyDrawThemeParentBackground)(HWND,HDC,RECT *);
+static HRESULT (WINAPI *MyDrawThemeBackground)(HANDLE,HDC,int,int,const RECT *,const RECT *);
+static HRESULT (WINAPI *MyDrawThemeText)(HANDLE,HDC,int,int,LPCWSTR,int,DWORD,DWORD,const RECT *);
+
+static CRITICAL_SECTION csTips;
+static HWND hwndToolTips = NULL;
+
+int UnloadButtonModule(WPARAM wParam, LPARAM lParam) {
+ DeleteCriticalSection(&csTips);
+ return 0;
+}
+
+int LoadButtonModule(void) {
+ WNDCLASSEX wc;
+
+ ZeroMemory(&wc, sizeof(wc));
+ wc.cbSize = sizeof(wc);
+ wc.lpszClassName = MYMIRANDABUTTONCLASS;
+ wc.lpfnWndProc = MButtonWndProc;
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.cbWndExtra = sizeof(MButtonCtrl*);
+ wc.hbrBackground = 0;
+ wc.style = CS_GLOBALCLASS;
+ RegisterClassEx(&wc);
+ InitializeCriticalSection(&csTips);
+ HookEvent(ME_SYSTEM_SHUTDOWN, UnloadButtonModule);
+ return 0;
+}
+
+// Used for our own cheap TrackMouseEvent
+#define BUTTON_POLLID 100
+#define BUTTON_POLLDELAY 50
+
+#define MGPROC(x) GetProcAddress(themeAPIHandle,x)
+static int ThemeSupport() {
+ if (IsWinVerXPPlus()) {
+ if (!themeAPIHandle) {
+ themeAPIHandle = GetModuleHandle("uxtheme");
+ if (themeAPIHandle) {
+ MyOpenThemeData = (HANDLE (WINAPI *)(HWND,LPCWSTR))MGPROC("OpenThemeData");
+ MyCloseThemeData = (HRESULT (WINAPI *)(HANDLE))MGPROC("CloseThemeData");
+ MyIsThemeBackgroundPartiallyTransparent = (BOOL (WINAPI *)(HANDLE,int,int))MGPROC("IsThemeBackgroundPartiallyTransparent");
+ MyDrawThemeParentBackground = (HRESULT (WINAPI *)(HWND,HDC,RECT *))MGPROC("DrawThemeParentBackground");
+ MyDrawThemeBackground = (HRESULT (WINAPI *)(HANDLE,HDC,int,int,const RECT *,const RECT *))MGPROC("DrawThemeBackground");
+ MyDrawThemeText = (HRESULT (WINAPI *)(HANDLE,HDC,int,int,LPCWSTR,int,DWORD,DWORD,const RECT *))MGPROC("DrawThemeText");
+ }
+ }
+ // Make sure all of these methods are valid (i would hope either all or none work)
+ if (MyOpenThemeData
+ &&MyCloseThemeData
+ &&MyIsThemeBackgroundPartiallyTransparent
+ &&MyDrawThemeParentBackground
+ &&MyDrawThemeBackground
+ &&MyDrawThemeText) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void DestroyTheme(MButtonCtrl *ctl) {
+ if (ThemeSupport()) {
+ if (ctl->hThemeButton) {
+ MyCloseThemeData(ctl->hThemeButton);
+ ctl->hThemeButton = NULL;
+ }
+ if (ctl->hThemeToolbar) {
+ MyCloseThemeData(ctl->hThemeToolbar);
+ ctl->hThemeToolbar = NULL;
+ }
+ }
+}
+
+static void LoadTheme(MButtonCtrl *ctl) {
+ if (ThemeSupport()) {
+ DestroyTheme(ctl);
+ ctl->hThemeButton = MyOpenThemeData(ctl->hwnd,L"BUTTON");
+ ctl->hThemeToolbar = MyOpenThemeData(ctl->hwnd,L"TOOLBAR");
+ }
+}
+
+static int TBStateConvert2Flat(int state) {
+ switch(state) {
+ case PBS_NORMAL: return TS_NORMAL;
+ case PBS_HOT: return TS_HOT;
+ case PBS_PRESSED: return TS_PRESSED;
+ case PBS_DISABLED: return TS_DISABLED;
+ case PBS_DEFAULTED: return TS_NORMAL;
+ }
+ return TS_NORMAL;
+}
+
+static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) {
+ if (hdcPaint) {
+ HDC hdcMem;
+ HBITMAP hbmMem;
+ HDC hOld;
+ RECT rcClient;
+
+ GetClientRect(ctl->hwnd, &rcClient);
+ hdcMem = CreateCompatibleDC(hdcPaint);
+ hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top);
+ hOld = SelectObject(hdcMem, hbmMem);
+
+ // If its a push button, check to see if it should stay pressed
+ if (ctl->pushBtn && ctl->pbState) ctl->stateId = PBS_PRESSED;
+
+ // Draw the flat button
+ if (ctl->flatBtn) {
+ if (ctl->hThemeToolbar) {
+ int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId==PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED;
+ if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) {
+ MyDrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient);
+ }
+ MyDrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rcClient, &rcClient);
+ }
+ else {
+ HBRUSH hbr;
+
+ if (ctl->stateId==PBS_PRESSED||ctl->stateId==PBS_HOT)
+ hbr = GetSysColorBrush(COLOR_3DLIGHT);
+ else {
+ HDC dc;
+ HWND hwndParent;
+
+ hwndParent = GetParent(ctl->hwnd);
+ dc=GetDC(hwndParent);
+ hbr = (HBRUSH)SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM)dc, (LPARAM)hwndParent);
+ ReleaseDC(hwndParent,dc);
+ }
+ if (hbr) {
+ FillRect(hdcMem, &rcClient, hbr);
+ DeleteObject(hbr);
+ }
+ if (ctl->stateId==PBS_HOT||ctl->focus) {
+ if (ctl->pbState)
+ DrawEdge(hdcMem,&rcClient, EDGE_ETCHED,BF_RECT|BF_SOFT);
+ else DrawEdge(hdcMem,&rcClient, BDR_RAISEDOUTER,BF_RECT|BF_SOFT|BF_FLAT);
+ }
+ else if (ctl->stateId==PBS_PRESSED)
+ DrawEdge(hdcMem, &rcClient, BDR_SUNKENOUTER,BF_RECT|BF_SOFT);
+ }
+ }
+ else {
+ // Draw background/border
+ if (ctl->hThemeButton) {
+ int state = IsWindowEnabled(ctl->hwnd)?(ctl->stateId==PBS_NORMAL&&ctl->defbutton?PBS_DEFAULTED:ctl->stateId):PBS_DISABLED;
+ if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) {
+ MyDrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient);
+ }
+ MyDrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient);
+ }
+ else {
+ UINT uState = DFCS_BUTTONPUSH|((ctl->stateId==PBS_HOT)?DFCS_HOT:0)|((ctl->stateId == PBS_PRESSED)?DFCS_PUSHED:0);
+ if (ctl->defbutton&&ctl->stateId==PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON;
+ DrawFrameControl(hdcMem, &rcClient, DFC_BUTTON, uState);
+ }
+
+ // Draw focus rectangle if button has focus
+ if (ctl->focus) {
+ RECT focusRect = rcClient;
+ InflateRect(&focusRect, -3, -3);
+ DrawFocusRect(hdcMem, &focusRect);
+ }
+ }
+
+ // If we have an icon or a bitmap, ignore text and only draw the image on the button
+ if (ctl->hIcon) {
+ int ix = (rcClient.right-rcClient.left)/2 - (GetSystemMetrics(SM_CXSMICON)/2);
+ int iy = (rcClient.bottom-rcClient.top)/2 - (GetSystemMetrics(SM_CYSMICON)/2);
+ if (ctl->stateId == PBS_PRESSED) {
+ ix++;
+ iy++;
+ }
+ {
+ HIMAGELIST hImageList;
+ HICON hIconNew;
+
+ hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), IsWinVerXPPlus()? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0);
+ ImageList_AddIcon(hImageList, ctl->hIcon);
+ hIconNew = ImageList_GetIcon(hImageList, 0, ILD_NORMAL);
+ DrawState(hdcMem,NULL,NULL,(LPARAM)hIconNew,0,ix,iy,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),IsWindowEnabled(ctl->hwnd)?DST_ICON|DSS_NORMAL:DST_ICON|DSS_DISABLED);
+ ImageList_RemoveAll(hImageList);
+ ImageList_Destroy(hImageList);
+ DestroyIcon(hIconNew);
+ }
+ }
+ else if (ctl->hBitmap) {
+ BITMAP bminfo;
+ int ix,iy;
+
+ GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo);
+ ix = (rcClient.right-rcClient.left)/2 - (bminfo.bmWidth/2);
+ iy = (rcClient.bottom-rcClient.top)/2 - (bminfo.bmHeight/2);
+ if (ctl->stateId == PBS_PRESSED) {
+ ix++;
+ iy++;
+ }
+ DrawState(hdcMem,NULL,NULL,(LPARAM)ctl->hBitmap,0,ix,iy,bminfo.bmWidth,bminfo.bmHeight,IsWindowEnabled(ctl->hwnd)?DST_BITMAP:DST_BITMAP|DSS_DISABLED);
+ }
+ else if (GetWindowTextLength(ctl->hwnd)) {
+ // Draw the text and optinally the arrow
+ char szText[MAX_PATH];
+ SIZE sz;
+ RECT rcText;
+ HFONT hOldFont;
+
+ CopyRect(&rcText, &rcClient);
+ GetWindowText(ctl->hwnd, szText, sizeof(szText));
+ SetBkMode(hdcMem, TRANSPARENT);
+ hOldFont = SelectObject(hdcMem, ctl->hFont);
+ // XP w/themes doesn't used the glossy disabled text. Is it always using COLOR_GRAYTEXT? Seems so.
+ SetTextColor(hdcMem, IsWindowEnabled(ctl->hwnd)||!ctl->hThemeButton?GetSysColor(COLOR_BTNTEXT):GetSysColor(COLOR_GRAYTEXT));
+ GetTextExtentPoint32(hdcMem, szText, lstrlen(szText), &sz);
+ if (ctl->cHot) {
+ SIZE szHot;
+
+ GetTextExtentPoint32(hdcMem, "&", 1, &szHot);
+ sz.cx -= szHot.cx;
+ }
+ if (ctl->arrow) {
+ DrawState(hdcMem,NULL,NULL,(LPARAM)ctl->arrow,0,rcClient.right-rcClient.left-5-GetSystemMetrics(SM_CXSMICON)+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),(rcClient.bottom-rcClient.top)/2-GetSystemMetrics(SM_CYSMICON)/2+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),IsWindowEnabled(ctl->hwnd)?DST_ICON:DST_ICON|DSS_DISABLED);
+ }
+ SelectObject(hdcMem, ctl->hFont);
+ DrawState(hdcMem,NULL,NULL,(LPARAM)szText,0,(rcText.right-rcText.left-sz.cx)/2+(!ctl->hThemeButton&&ctl->stateId==PBS_PRESSED?1:0),ctl->hThemeButton?(rcText.bottom-rcText.top-sz.cy)/2:(rcText.bottom-rcText.top-sz.cy)/2-(ctl->stateId==PBS_PRESSED?0:1),sz.cx,sz.cy,IsWindowEnabled(ctl->hwnd)||ctl->hThemeButton?DST_PREFIXTEXT|DSS_NORMAL:DST_PREFIXTEXT|DSS_DISABLED);
+ SelectObject(hdcMem, hOldFont);
+ }
+ BitBlt(hdcPaint, 0, 0, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top, hdcMem, 0, 0, SRCCOPY);
+ SelectObject(hdcMem, hOld);
+ DeleteObject(hbmMem);
+ DeleteDC(hdcMem);
+
+ }
+}
+
+static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+ MButtonCtrl* bct = (MButtonCtrl *)GetWindowLong(hwndDlg, 0);
+ switch(msg) {
+ case WM_NCCREATE:
+ {
+ SetWindowLong(hwndDlg, GWL_STYLE, GetWindowLong(hwndDlg, GWL_STYLE)|BS_OWNERDRAW);
+ bct = malloc(sizeof(MButtonCtrl));
+ if (bct==NULL) return FALSE;
+ bct->hwnd = hwndDlg;
+ bct->stateId = PBS_NORMAL;
+ bct->focus = 0;
+ bct->hFont = GetStockObject(DEFAULT_GUI_FONT);
+ bct->arrow = NULL;
+ bct->defbutton = 0;
+ bct->hIcon = NULL;
+ bct->hBitmap = NULL;
+ bct->pushBtn = 0;
+ bct->pbState = 0;
+ bct->hThemeButton = NULL;
+ bct->hThemeToolbar = NULL;
+ bct->cHot = 0;
+ bct->flatBtn = 0;
+ LoadTheme(bct);
+ SetWindowLong(hwndDlg, 0, (LONG)bct);
+ if (((CREATESTRUCT *)lParam)->lpszName) SetWindowText(hwndDlg, ((CREATESTRUCT *)lParam)->lpszName);
+ return TRUE;
+ }
+ case WM_DESTROY:
+ {
+ if (bct) {
+ EnterCriticalSection(&csTips);
+ if (hwndToolTips) {
+ TOOLINFO ti;
+
+ ZeroMemory(&ti, sizeof(ti));
+ ti.cbSize = sizeof(ti);
+ ti.uFlags = TTF_IDISHWND;
+ ti.hwnd = bct->hwnd;
+ ti.uId = (UINT)bct->hwnd;
+ if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) {
+ SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti);
+ }
+ if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM)&ti)==0) {
+ DestroyWindow(hwndToolTips);
+ hwndToolTips = NULL;
+ }
+ }
+ LeaveCriticalSection(&csTips);
+ DestroyTheme(bct);
+ free(bct);
+ }
+ SetWindowLong(hwndDlg,0,(LONG)NULL);
+ break; // DONT! fall thru
+ }
+ case WM_SETTEXT:
+ {
+ bct->cHot = 0;
+ if ((char*)lParam) {
+ char *tmp = (char*)lParam;
+ while (*tmp) {
+ if (*tmp=='&' && *(tmp+1)) {
+ bct->cHot = tolower(*(tmp+1));
+ break;
+ }
+ tmp++;
+ }
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ }
+ case WM_SYSKEYUP:
+ if (bct->stateId!=PBS_DISABLED && bct->cHot && bct->cHot == tolower((int)wParam)) {
+ if (bct->pushBtn) {
+ if (bct->pbState) bct->pbState = 0;
+ else bct->pbState = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
+ return 0;
+ }
+ break;
+ case WM_THEMECHANGED: {
+ // themed changed, reload theme object
+ LoadTheme(bct);
+ InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it
+ break;
+ }
+ case WM_SETFONT: // remember the font so we can use it later
+ {
+ bct->hFont = (HFONT)wParam; // maybe we should redraw?
+ break;
+ }
+ case WM_NCPAINT:
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ HDC hdcPaint;
+
+ hdcPaint = BeginPaint(hwndDlg, &ps);
+ if (hdcPaint) {
+ PaintWorker(bct, hdcPaint);
+ EndPaint(hwndDlg, &ps);
+ }
+ break;
+ }
+ case BM_SETIMAGE:
+ if (wParam == IMAGE_ICON) {
+ bct->hIcon = (HICON)lParam;
+ bct->hBitmap = NULL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ else if (wParam == IMAGE_BITMAP) {
+ bct->hBitmap = (HBITMAP)lParam;
+ bct->hIcon = NULL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ case BM_SETCHECK:
+ if (!bct->pushBtn) break;
+ if (wParam == BST_CHECKED) {
+ bct->pbState = 1;
+ bct->stateId = PBS_PRESSED;
+ }
+ else if (wParam == BST_UNCHECKED) {
+ bct->pbState = 0;
+ bct->stateId = PBS_NORMAL;
+ }
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BM_GETCHECK:
+ if (bct->pushBtn) {
+ return bct->pbState?BST_CHECKED:BST_UNCHECKED;
+ }
+ return 0;
+ case BUTTONSETARROW: // turn arrow on/off
+ if (wParam) {
+// if (!bct->arrow)
+// bct->arrow = (HICON)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DOWNARROW),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0);
+ }
+ else {
+ if (bct->arrow) {
+ DestroyIcon(bct->arrow);
+ bct->arrow = NULL;
+ }
+ }
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONSETDEFAULT:
+ bct->defbutton = wParam?1:0;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONSETASPUSHBTN:
+ bct->pushBtn = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONSETASFLATBTN:
+ bct->flatBtn = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case BUTTONADDTOOLTIP:
+ {
+ TOOLINFO ti;
+
+ if (!(char*)wParam) break;
+ EnterCriticalSection(&csTips);
+ if (!hwndToolTips) {
+ hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
+ }
+ ZeroMemory(&ti, sizeof(ti));
+ ti.cbSize = sizeof(ti);
+ ti.uFlags = TTF_IDISHWND;
+ ti.hwnd = bct->hwnd;
+ ti.uId = (UINT)bct->hwnd;
+ if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) {
+ SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti);
+ }
+ ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS;
+ ti.uId = (UINT)bct->hwnd;
+ ti.lpszText=(char*)wParam;
+ SendMessage(hwndToolTips,TTM_ADDTOOL,0,(LPARAM)&ti);
+ LeaveCriticalSection(&csTips);
+ break;
+ }
+ case WM_SETFOCUS: // set keybord focus and redraw
+ bct->focus = 1;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case WM_KILLFOCUS: // kill focus and redraw
+ bct->focus = 0;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case WM_WINDOWPOSCHANGED:
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ case WM_ENABLE: // windows tells us to enable/disable
+ {
+ bct->stateId = wParam?PBS_NORMAL:PBS_DISABLED;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ break;
+ }
+ case WM_MOUSELEAVE: // faked by the WM_TIMER
+ {
+ if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled
+ bct->stateId = PBS_NORMAL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ }
+ case WM_LBUTTONDOWN:
+ {
+ if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled
+ bct->stateId = PBS_PRESSED;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ break;
+ }
+ case WM_LBUTTONUP:
+ {
+ if (bct->pushBtn) {
+ if (bct->pbState) bct->pbState = 0;
+ else bct->pbState = 1;
+ }
+ if (bct->stateId!=PBS_DISABLED) { // don't change states if disabled
+ if (msg==WM_LBUTTONUP) bct->stateId = PBS_HOT;
+ else bct->stateId = PBS_NORMAL;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ // Tell your daddy you got clicked.
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM)hwndDlg);
+ break;
+ }
+ case WM_MOUSEMOVE:
+ if (bct->stateId == PBS_NORMAL) {
+ bct->stateId = PBS_HOT;
+ InvalidateRect(bct->hwnd, NULL, TRUE);
+ }
+ // Call timer, used to start cheesy TrackMouseEvent faker
+ SetTimer(hwndDlg,BUTTON_POLLID,BUTTON_POLLDELAY,NULL);
+ break;
+ case WM_TIMER: // use a timer to check if they have did a mouseout
+ {
+ if (wParam==BUTTON_POLLID) {
+ RECT rc;
+ POINT pt;
+ GetWindowRect(hwndDlg,&rc);
+ GetCursorPos(&pt);
+ if(!PtInRect(&rc,pt)) { // mouse must be gone, trigger mouse leave
+ PostMessage(hwndDlg,WM_MOUSELEAVE,0,0L);
+ KillTimer(hwndDlg,BUTTON_POLLID);
+ }
+ }
+ break;
+ }
+ case WM_ERASEBKGND:
+ return 1;
+ }
+ return DefWindowProc(hwndDlg, msg, wParam, lParam);
+}
diff --git a/plugins/TopToolBar/buttonopt.c b/plugins/TopToolBar/buttonopt.c
new file mode 100644
index 0000000000..b1d8275953
--- /dev/null
+++ b/plugins/TopToolBar/buttonopt.c
@@ -0,0 +1,340 @@
+#include "common.h"
+#pragma hdrstop
+
+extern HINSTANCE hInst;
+
+char *DBGetString(HANDLE hContact,const char *szModule,const char *szSetting)
+{
+ char *str=NULL;
+ DBVARIANT dbv;
+ DBGetContactSetting(hContact,szModule,szSetting,&dbv);
+ if(dbv.type==DBVT_ASCIIZ)
+ str=strdup(dbv.pszVal);
+ DBFreeVariant(&dbv);
+ return str;
+}
+
+
+
+
+struct OrderData {
+ int dragging;
+ HTREEITEM hDragItem;
+};
+
+
+
+int CheckButtonOrder()
+{
+ boolean protochanged=FALSE;
+ int StoredButCount;
+ int i,count;
+ int v;
+ char buf[10];
+ char buf2[10];
+
+ //curproto=0;
+ //curproto[1]='22';
+
+ StoredButCount=DBGetContactSettingByte(0,TTB_OPTDIR,"ButCount",-1);
+ if (StoredButCount==-1){protochanged=TRUE;};
+ if (protochanged)
+ {
+ //reseting all settings;
+
+ CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&count,(LPARAM)&protos);
+
+ v=0;
+ for(i=0;i<count;i++) {
+ if(protos[i]->type!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue;
+ itoa(v,&buf,10);
+ DBWriteContactSettingString(0,"Protocols",&buf,protos[i]->szName);
+
+ itoa(OFFSET_VISIBLE+v,&buf,10);//save default visible status
+ DBWriteContactSettingByte(0,"Protocols",&buf,1);
+
+ v++;
+ };
+ DBWriteContactSettingByte(0,TTB_OPTDIR,"ButCount",v);
+ return(1);
+ }
+ else
+ {
+ return(0);
+ };
+
+
+
+};
+
+
+
+static BOOL CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{ struct ProtocolOrderData *dat;
+
+ dat=(struct ProtocolOrderData*)GetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),GWL_USERDATA);
+
+ switch (msg)
+ {
+ case WM_INITDIALOG: {
+ PROTOCOLDESCRIPTOR **protos;
+ TVINSERTSTRUCT tvis;
+ ProtocolData *PD;
+ char szName[64];
+ char *szSTName;
+ char buf[10];
+ int i,count;
+
+ dat=(struct ProtocolOrderData*)malloc(sizeof(struct ProtocolOrderData));
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),GWL_USERDATA,(LONG)dat);
+ dat->dragging=0;
+
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),GWL_STYLE,GetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),GWL_STYLE)|TVS_NOHSCROLL);
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),GWL_STYLE,GetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),GWL_STYLE)|TVS_NOHSCROLL);
+
+ { HIMAGELIST himlCheckBoxes;
+ himlCheckBoxes=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR4|ILC_MASK,2,2);
+ ImageList_AddIcon(himlCheckBoxes,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_NOTICK)));
+ ImageList_AddIcon(himlCheckBoxes,LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_TICK)));
+ TreeView_SetImageList(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),himlCheckBoxes,TVSIL_NORMAL);
+ //
+ TreeView_SetImageList(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),himlCheckBoxes,TVSIL_NORMAL);
+
+ }
+
+ tvis.hParent=NULL;
+ tvis.hInsertAfter=TVI_LAST;
+ tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+
+ CheckProtocolOrder();
+
+ count=DBGetContactSettingByte(0,"Protocols","ProtoCount",-1);
+ if (count==-1){return(FALSE);};
+
+ for(i=0;i<count;i++) {
+ //if(protos[i]->type!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue;
+ itoa(i,&buf,10);
+ szSTName=DBGetString(0,"Protocols",&buf);
+ if (szSTName==NULL){continue;};
+
+ CallProtoService(szSTName,PS_GETNAME,sizeof(szName),(LPARAM)szName);
+ PD=(ProtocolData*)malloc(sizeof(ProtocolData));
+
+
+ PD->RealName=szSTName;
+
+ itoa(OFFSET_VISIBLE+i,&buf,10);
+ PD->show=DBGetContactSettingByte(0,"Protocols",&buf,1);
+
+ itoa(OFFSET_PROTOPOS+i,&buf,10);
+ PD->protopos=DBGetContactSettingByte(0,"Protocols",&buf,-1);
+
+ tvis.item.lParam=(LPARAM)PD;
+ tvis.item.pszText=Translate(szName);
+ tvis.item.iImage=tvis.item.iSelectedImage=PD->show;
+ TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&tvis);
+ tvis.item.iImage=tvis.item.iSelectedImage=PD->show;
+ TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),&tvis);
+
+ //free(szSTName);
+ }
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ TVITEM tvi;
+ PROTOCOLDESCRIPTOR **protos;
+ int count;
+ char idstr[33];
+ char buf[10];
+
+ /*
+ tvi.hItem=TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY));
+ tvi.cchTextMax=32;
+ tvi.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_PARAM|TVIF_HANDLE;
+ tvi.pszText=&idstr;
+ //count=0;
+ while(tvi.hItem!=NULL) {
+ itoa(OFFSET_VISIBLE+count,&buf,10);
+ TreeView_GetItem(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),&tvi);
+ DBWriteContactSettingByte(NULL,"Protocols",&buf,(byte)tvi.iImage);
+ tvi.hItem=TreeView_GetNextSibling(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),tvi.hItem);
+ //count++;
+ }
+ */
+ tvi.hItem=TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER));
+ tvi.cchTextMax=32;
+ tvi.mask=TVIF_TEXT|TVIF_PARAM|TVIF_HANDLE;
+ tvi.pszText=&idstr;
+ //CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&count,(LPARAM)&protos);
+ //count--;
+ count=0;
+
+ while(tvi.hItem!=NULL) {
+ itoa(count,buf,10);
+ TreeView_GetItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&tvi);
+ DBWriteContactSettingString(NULL,"Protocols",&buf,((ProtocolData *)tvi.lParam)->RealName);
+
+ itoa(OFFSET_PROTOPOS+count,&buf,10);//save pos in protos
+ DBWriteContactSettingByte(0,"Protocols",&buf,((ProtocolData *)tvi.lParam)->protopos);
+
+ itoa(OFFSET_VISIBLE+count,&buf,10);//save pos in protos
+ DBWriteContactSettingByte(0,"Protocols",&buf,((ProtocolData *)tvi.lParam)->show);
+
+ tvi.hItem=TreeView_GetNextSibling(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),tvi.hItem);
+
+ count++;
+ }
+ CluiProtocolStatusChanged(0,0);
+ }
+ }
+ break;
+ /*
+ case IDC_PROTOCOLORDER: //IDC_PROTOCOLVISIBILITY:
+ if(((LPNMHDR)lParam)->code==NM_CLICK) {
+ TVHITTESTINFO hti;
+ hti.pt.x=(short)LOWORD(GetMessagePos());
+ hti.pt.y=(short)HIWORD(GetMessagePos());
+ ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt);
+ if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti))
+ if(hti.flags&TVHT_ONITEMICON) {
+ TVITEM tvi;
+ tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ tvi.hItem=hti.hItem;
+ TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi);
+ tvi.iImage=tvi.iSelectedImage=!tvi.iImage;
+ ((ProtocolData *)tvi.lParam)->show=tvi.iImage;
+ TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom,&tvi);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ ShowWindow(GetDlgItem(hwndDlg,IDC_PROTOCOLORDERWARNING),SW_SHOW);
+ }
+ }
+ break;
+ */
+ case IDC_PROTOCOLORDER:
+ switch (((LPNMHDR)lParam)->code) {
+ case TVN_BEGINDRAG:
+ SetCapture(hwndDlg);
+ dat->dragging=1;
+ dat->hDragItem=((LPNMTREEVIEW)lParam)->itemNew.hItem;
+ TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),dat->hDragItem);
+ //ShowWindow(GetDlgItem(hwndDlg,IDC_PROTOCOLORDERWARNING),SW_SHOW);
+ break;
+ case NM_CLICK:
+ {
+
+ TVHITTESTINFO hti;
+ hti.pt.x=(short)LOWORD(GetMessagePos());
+ hti.pt.y=(short)HIWORD(GetMessagePos());
+ ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt);
+ if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti))
+ if(hti.flags&TVHT_ONITEMICON) {
+ TVITEM tvi;
+ tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ tvi.hItem=hti.hItem;
+ TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi);
+ tvi.iImage=tvi.iSelectedImage=!tvi.iImage;
+ ((ProtocolData *)tvi.lParam)->show=tvi.iImage;
+ TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom,&tvi);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+
+ //all changes take effect in runtime
+ //ShowWindow(GetDlgItem(hwndDlg,IDC_PROTOCOLORDERWARNING),SW_SHOW);
+ }
+
+
+
+ };
+ }
+ break;
+ }
+ break;
+ case WM_MOUSEMOVE:
+ if(!dat->dragging) break;
+ { TVHITTESTINFO hti;
+ hti.pt.x=(short)LOWORD(lParam);
+ hti.pt.y=(short)HIWORD(lParam);
+ ClientToScreen(hwndDlg,&hti.pt);
+ ScreenToClient(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&hti.pt);
+ TreeView_HitTest(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&hti);
+ if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) {
+ hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER))/2;
+ TreeView_HitTest(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&hti);
+ TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),hti.hItem,1);
+ }
+ else {
+ if(hti.flags&TVHT_ABOVE) SendDlgItemMessage(hwndDlg,IDC_PROTOCOLORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),0);
+ if(hti.flags&TVHT_BELOW) SendDlgItemMessage(hwndDlg,IDC_PROTOCOLORDER,WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),0);
+ TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),NULL,0);
+ }
+ }
+ break;
+ case WM_LBUTTONUP:
+ if(!dat->dragging) break;
+ TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),NULL,0);
+ dat->dragging=0;
+ ReleaseCapture();
+ { TVHITTESTINFO hti;
+ TVITEM tvi;
+ hti.pt.x=(short)LOWORD(lParam);
+ hti.pt.y=(short)HIWORD(lParam);
+ ClientToScreen(hwndDlg,&hti.pt);
+ ScreenToClient(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&hti.pt);
+ hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER))/2;
+ TreeView_HitTest(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&hti);
+ if(dat->hDragItem==hti.hItem) break;
+ tvi.mask=TVIF_HANDLE|TVIF_PARAM;
+ tvi.hItem=hti.hItem;
+ TreeView_GetItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&tvi);
+ if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) {
+ TVINSERTSTRUCT tvis;
+ char name[128];
+ tvis.item.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ tvis.item.stateMask=0xFFFFFFFF;
+ tvis.item.pszText=name;
+ tvis.item.cchTextMax=sizeof(name);
+ tvis.item.hItem=dat->hDragItem;
+ //
+ tvis.item.iImage=tvis.item.iSelectedImage=((ProtocolData *)tvi.lParam)->show;
+
+ TreeView_GetItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&tvis.item);
+
+
+ TreeView_DeleteItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),dat->hDragItem);
+ tvis.hParent=NULL;
+ tvis.hInsertAfter=hti.hItem;
+ TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_PROTOCOLORDER),&tvis));
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static int ProtocolOrderInit(WPARAM wParam,LPARAM lParam) {
+ OPTIONSDIALOGPAGE odp;
+
+ ZeroMemory(&odp,sizeof(odp));
+ odp.cbSize=sizeof(odp);
+ odp.position=-1000000000;
+ odp.hInstance=hInst;//GetModuleHandle(NULL);
+ odp.pszTemplate=MAKEINTRESOURCE(IDD_OPT_PROTOCOLORDER);
+ odp.pszGroup=Translate("Contact List");
+ odp.pszTitle=Translate("Protocols");
+ odp.pfnDlgProc=ProtocolOrderOpts;
+ odp.flags=ODPF_BOLDGROUPS|ODPF_EXPERTONLY;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+
+ return 0;
+}
+
+int LoadProtocolOrderModule(void) {
+ HookEvent(ME_OPT_INITIALISE,ProtocolOrderInit);
+ return 0;
+} \ No newline at end of file
diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h
new file mode 100644
index 0000000000..3150ca3a23
--- /dev/null
+++ b/plugins/TopToolBar/common.h
@@ -0,0 +1,150 @@
+#ifndef TTB_COMMON_H
+#define TTB_COMMON_H
+
+
+#define _CRT_SECURE_NO_WARNINGS
+
+#include <windows.h>
+#include <commctrl.h>
+#include <time.h>
+#include <stddef.h>
+#include <process.h>
+#include <math.h>
+#include <vsstyle.h>
+
+#include "win2k.h"
+#include "newpluginapi.h"
+#include "m_system.h"
+#include "m_database.h"
+#include "m_clist.h"
+#include "m_skin.h"
+#include "m_utils.h"
+#include "m_cluiframes.h"
+#include "m_clui.h"
+#include "m_clc.h"
+#include "m_langpack.h"
+#include "m_options.h"
+#include "resource.h"
+#include "m_toptoolbar.h"
+#include "m_button.h"
+#include "m_icolib.h"
+#include "BkgrCfg.h"
+
+#define TTB_OPTDIR "TopToolBar"
+#define TTBDEFAULT_BKBMPUSE CLB_STRETCH
+
+
+#define TTBDEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE)
+#define TTBDEFAULT_USEBITMAP 0
+#define TTBDEFAULT_SELBKCOLOUR GetSysColor(COLOR_HIGHLIGHT)
+
+int TTBOptInit(WPARAM wParam,LPARAM lParam);
+//append string
+char __inline *AS(char *str,const char *setting,char *addstr);
+
+int ttbOptionsChanged();
+
+int ArrangeButtons();
+int RecreateWindows();
+
+typedef struct {
+ HWND hwnd;
+ HWND hwndTip;
+ int id;
+ BOOL bPushed;
+ int dwFlags;
+ int x,y;
+ HBITMAP hbBitmapUp,hbBitmapDown;
+ HBITMAP hbDefBitmapUp,hbDefBitmapDown;
+ HBITMAP hbWBordBitmapUp,hbWBordBitmapDown;
+ HICON hIconUp,hIconDn;
+
+ char *pszServiceUp,*pszServiceDown;
+ char *tooltip;
+ char *name;
+
+ LPARAM lParamUp;
+ WPARAM wParamUp;
+ LPARAM lParamDown;
+ WPARAM wParamDown;
+ WORD arrangedpos;
+ char *UserDefinedbmUp;
+ char *UserDefinedbmDown;
+
+
+}TopButtonInt;
+
+typedef struct tagSortData {
+ int oldpos;
+ int arrangeval;
+} SortData;
+
+#define MAX_BUTTONS 64
+//#define BUTTWIDTH 20
+
+//#define BUTTHEIGHT 16
+#define SEPWIDTH 3
+
+typedef struct tagButtonOptData {
+ char *name;
+ int pos;
+ boolean show;
+} ButtonOptData;
+
+boolean OptionsOpened;
+HWND OptionshWnd;
+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)
+{
+ if(str!=NULL) {
+ strcpy(str,setting);
+ strcat(str,addstr);
+ }
+ return str;
+};
+
+
+char *DBGetString(HANDLE hContact,const char *szModule,const char *szSetting);
+
+
+#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 "MyMIRANDABUTTONCLASS"
+
+
+int InitLBut();
+int UnInitLBut();
+
+typedef struct
+{
+int hframe;
+char *lpath;
+char *name;
+}LBUTOPT;
+
+int LoadCLCButtonModule(void);
+#define BM_SETPRIVATEICON (WM_USER + 6)
+#define BM_SETIMLICON (WM_USER + 7)
+#define UseIcoLibDefaultValue 0
+#define UseMirandaButtonClassDefaultValue 1
+
+#endif \ No newline at end of file
diff --git a/plugins/TopToolBar/find.ico b/plugins/TopToolBar/find.ico
new file mode 100644
index 0000000000..415a0bccd7
--- /dev/null
+++ b/plugins/TopToolBar/find.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Find_Add Contacts_DN.ico b/plugins/TopToolBar/icos/Find_Add Contacts_DN.ico
new file mode 100644
index 0000000000..06027e5bbe
--- /dev/null
+++ b/plugins/TopToolBar/icos/Find_Add Contacts_DN.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Find_Add Contacts_UP.ico b/plugins/TopToolBar/icos/Find_Add Contacts_UP.ico
new file mode 100644
index 0000000000..452f2efc98
--- /dev/null
+++ b/plugins/TopToolBar/icos/Find_Add Contacts_UP.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Groups On_Off_DN.ico b/plugins/TopToolBar/icos/Groups On_Off_DN.ico
new file mode 100644
index 0000000000..99b7dddd38
--- /dev/null
+++ b/plugins/TopToolBar/icos/Groups On_Off_DN.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Groups On_Off_UP.ico b/plugins/TopToolBar/icos/Groups On_Off_UP.ico
new file mode 100644
index 0000000000..fffe8e32c4
--- /dev/null
+++ b/plugins/TopToolBar/icos/Groups On_Off_UP.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Minimize Button_DN.ico b/plugins/TopToolBar/icos/Minimize Button_DN.ico
new file mode 100644
index 0000000000..1fc45867e8
--- /dev/null
+++ b/plugins/TopToolBar/icos/Minimize Button_DN.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Minimize Button_UP.ico b/plugins/TopToolBar/icos/Minimize Button_UP.ico
new file mode 100644
index 0000000000..dd9a8451d7
--- /dev/null
+++ b/plugins/TopToolBar/icos/Minimize Button_UP.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Run.ico b/plugins/TopToolBar/icos/Run.ico
new file mode 100644
index 0000000000..7a87fadc82
--- /dev/null
+++ b/plugins/TopToolBar/icos/Run.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Show Main Menu_DN.ico b/plugins/TopToolBar/icos/Show Main Menu_DN.ico
new file mode 100644
index 0000000000..075649f4ac
--- /dev/null
+++ b/plugins/TopToolBar/icos/Show Main Menu_DN.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Show Main Menu_UP.ico b/plugins/TopToolBar/icos/Show Main Menu_UP.ico
new file mode 100644
index 0000000000..8602e4cf3e
--- /dev/null
+++ b/plugins/TopToolBar/icos/Show Main Menu_UP.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Show Options Page_DN.ico b/plugins/TopToolBar/icos/Show Options Page_DN.ico
new file mode 100644
index 0000000000..62558dbd69
--- /dev/null
+++ b/plugins/TopToolBar/icos/Show Options Page_DN.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Show Options Page_UP.ico b/plugins/TopToolBar/icos/Show Options Page_UP.ico
new file mode 100644
index 0000000000..d6945d94f5
--- /dev/null
+++ b/plugins/TopToolBar/icos/Show Options Page_UP.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Show only Online Users_DN.ico b/plugins/TopToolBar/icos/Show only Online Users_DN.ico
new file mode 100644
index 0000000000..87ef1abbb5
--- /dev/null
+++ b/plugins/TopToolBar/icos/Show only Online Users_DN.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Show only Online Users_UP.ico b/plugins/TopToolBar/icos/Show only Online Users_UP.ico
new file mode 100644
index 0000000000..e35e015123
--- /dev/null
+++ b/plugins/TopToolBar/icos/Show only Online Users_UP.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico b/plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico
new file mode 100644
index 0000000000..a52dd8a8fe
--- /dev/null
+++ b/plugins/TopToolBar/icos/Sounds Enable_Disable_DN.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico b/plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico
new file mode 100644
index 0000000000..31342f4ef5
--- /dev/null
+++ b/plugins/TopToolBar/icos/Sounds Enable_Disable_UP.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/icon1.ico b/plugins/TopToolBar/icos/icon1.ico
new file mode 100644
index 0000000000..bf61a00df5
--- /dev/null
+++ b/plugins/TopToolBar/icos/icon1.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/mirandad.ico b/plugins/TopToolBar/icos/mirandad.ico
new file mode 100644
index 0000000000..423daa96e1
--- /dev/null
+++ b/plugins/TopToolBar/icos/mirandad.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/mirandau.ico b/plugins/TopToolBar/icos/mirandau.ico
new file mode 100644
index 0000000000..423daa96e1
--- /dev/null
+++ b/plugins/TopToolBar/icos/mirandau.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/notick.ico b/plugins/TopToolBar/icos/notick.ico
new file mode 100644
index 0000000000..4ff17dfa7b
--- /dev/null
+++ b/plugins/TopToolBar/icos/notick.ico
Binary files differ
diff --git a/plugins/TopToolBar/icos/notick1.ico b/plugins/TopToolBar/icos/notick1.ico
new file mode 100644
index 0000000000..d24d6adbbf
--- /dev/null
+++ b/plugins/TopToolBar/icos/notick1.ico
Binary files differ
diff --git a/plugins/TopToolBar/launchbt.c b/plugins/TopToolBar/launchbt.c
new file mode 100644
index 0000000000..cffce36be0
--- /dev/null
+++ b/plugins/TopToolBar/launchbt.c
@@ -0,0 +1,211 @@
+#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 i;
+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)
+{
+ LBUTOPT *lbo=lParam;
+ if ((wParam<0)||(wParam>=MAXLBUTS)){return(-1);};
+ 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)
+{
+ LBUTOPT *lbo=lParam;
+ if ((wParam<0)||(wParam>=LButCnt)){return(-1);};
+ 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=_strdup(lbo->lpath);};
+
+ LBUTS[wParam].hframe=InsertLBut(wParam);
+ SaveAllLButs();
+ return(0);
+};
+
+int InsertLBut(int id)
+{
+ TTBButton ttb;
+
+ HBITMAP DefLUp;
+ HBITMAP DefLDn;
+
+ DefLDn=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_LAUNCHDN));
+ DefLUp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_LAUNCHUP));
+ //itoa(SeparatorCnt++,buf,10);
+
+ //wsprintf(buf,"%s %d",Translate("Separator"),id);
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ ttb.hbBitmapDown=DefLDn;
+ ttb.hbBitmapUp=DefLUp;
+ ttb.dwFlags=TTBBF_VISIBLE|TTBBF_ISLBUTTON;
+ ttb.pszServiceDown=TTB_LAUNCHSERVICE;
+ //ttb.pszServiceUp=TTB_LAUNCHSERVICE;
+ ttb.lParamDown=id;
+ ttb.name=LBUTS[id].name;
+ LButCnt++;
+ return(TTBAddButton(&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,i;
+// char *oldtb;
+
+ //must be locked
+ memset(buf,0,sizeof(buf));
+
+ memset(LBUTS,0,sizeof(LBUTS));
+ for (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=DBGetString(0,TTB_OPTDIR,AS(buf,fixname,"_lpath"));
+ if (LBUTS[i].lpath==NULL){LBUTS[i].lpath=_strdup("Execute Path");};
+ LBUTS[i].hframe=0;
+ LBUTS[i].hframe=InsertLBut(i);
+ };
+ };
+ return(0);
+
+};
+
+
+int SaveAllLButs()
+{
+ char buf[255];
+ char buf1[10];
+ char fixname[255];
+ int i;
+
+ //must be locked
+ memset(buf,0,sizeof(buf));
+
+ for (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);
+ DBWriteContactSettingString(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)
+ {
+ int i;
+ for (i=0;i<MAXLBUTS;i++)
+ {
+ if (LBUTS[i].hframe==0)
+ {
+ wsprintf(buf,"%s %d",Translate("Default"),i);
+ LBUTS[i].name=_strdup(buf);
+ LBUTS[i].lpath=_strdup("Execute Path");
+ LBUTS[i].hframe=InsertLBut(i);
+ SaveAllLButs();
+ return(0);
+ };
+ };
+ };
+
+ return(-1);
+};
+
+int InitLBut()
+{
+ CreateServiceFunction(TTB_LAUNCHSERVICE,LaunchService);
+ CreateServiceFunction(TTB_ADDLBUTTON,InsertNewFreeLBut);
+ CreateServiceFunction(TTB_REMOVELBUTTON,DeleteLBut);
+ CreateServiceFunction(TTB_MODIFYLBUTTON,ModifyLButton);
+ CreateServiceFunction(TTB_GETLBUTTON,GetLButton);
+
+
+
+ LoadAllLButs();
+ return(0);
+};
+int UnInitLBut()
+{
+ SaveAllLButs();
+ return(0);
+}; \ No newline at end of file
diff --git a/plugins/TopToolBar/main.c b/plugins/TopToolBar/main.c
new file mode 100644
index 0000000000..a3637b00b1
--- /dev/null
+++ b/plugins/TopToolBar/main.c
@@ -0,0 +1,1515 @@
+
+#include "common.h"
+#pragma hdrstop
+
+HINSTANCE hInst;
+PLUGINLINK *pluginLink;
+struct MM_INTERFACE mmi;
+HANDLE hModulesLoaded,hOptInit;
+HANDLE hHookTTBModuleLoaded;
+int hLangpack;
+
+HWND hwndContactList=0;
+HWND hwndTopToolBar=0;
+boolean StopArrange;
+
+int BUTTWIDTH=20;
+int BUTTHEIGHT=16;
+boolean UseIcoLib=FALSE;
+
+extern int LoadAllSeparators();
+extern int SaveAllSeparators();
+extern INT_PTR InsertNewFreeSeparator(WPARAM wParam,LPARAM lParam);
+extern INT_PTR DeleteSeparator(WPARAM id,LPARAM lParam);
+
+#define MIID_TTB {0xf593c752, 0x51d8, 0x4d46, {0xba, 0x27, 0x37, 0x57, 0x79, 0x53, 0xf5, 0x5c}}
+
+PLUGININFOEX pluginInfo={
+ sizeof(PLUGININFOEX),
+ "TopToolbar",
+ PLUGIN_MAKE_VERSION(0,7,3,1),
+ "ToptoolBar adds buttons in top frame for fast access.This plugin uses MultiWindow or CList_MW plugin.("__DATE__" "__TIME__")",
+ "Bethoven",
+ "Bethoven@mailgate.ru",
+ "© 2003-2008 Bethoven",
+ "http://www.miranda-im.org/",
+ UNICODE_AWARE,
+ 0, //doesn't replace anything built-in
+ MIID_TTB
+};
+
+
+
+
+int nextButtonId=200;
+int nButtonsCount=0;
+int lastxpos=1;
+int lastypos=1;
+
+
+
+
+//==============options
+COLORREF bkColour;
+HBITMAP hBmpBackground;
+int backgroundBmpUse;
+
+
+static CRITICAL_SECTION csButtonsHook;
+
+static int hFrameTopWindow=-1;
+
+
+TopButtonInt Buttons[MAX_BUTTONS];
+SortData arrangedbuts[MAX_BUTTONS];
+
+
+
+
+
+
+
+int SetButtBitmap(int pos);
+
+void lockbut()
+{
+ EnterCriticalSection(&csButtonsHook);
+}
+
+void ulockbut()
+{
+ LeaveCriticalSection(&csButtonsHook);
+}
+
+
+
+static int RemoveItemFromList(int pos,TopButtonInt (*lpButtons)[],int *ButtonsItemCount)
+{
+ memcpy(&((*lpButtons)[pos]),&((*lpButtons)[pos+1]),sizeof(TopButtonInt)*(*ButtonsItemCount-pos-1));
+ (*ButtonsItemCount)--;
+ //(*lpButtons)=(TopButtonInt*)realloc((*lpButtons),sizeof(TopButtonInt)*(*ButtonsItemCount));
+ return 0;
+}
+
+
+int idtopos(int id)
+{
+ int i;
+
+ for (i=0;i<nButtonsCount;i++)
+ {
+ if (Buttons[i].id==id){return(i);};
+ };
+ return(-1);
+};
+
+
+int DBSaveButtonSettings(int butpos)
+{
+ char buf[255];
+ DWORD oldv;
+// char *oldtb;
+
+ //must be locked
+ memset(buf,0,sizeof(buf));
+
+
+
+ DBWriteContactSettingWord(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_Position"),Buttons[butpos].arrangedpos);
+
+ oldv=Buttons[butpos].dwFlags&(TTBBF_VISIBLE);
+ DBWriteContactSettingDword(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_Visible"),oldv);
+
+ //Buttons[butpos].UserDefinedbmDown=DBGetString(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_BmpDown"));
+ DBWriteContactSettingString(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_BmpDown"),"");
+ DBWriteContactSettingString(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_BmpUp"),"");
+
+ if (Buttons[butpos].UserDefinedbmDown!=NULL)
+ {
+ DBWriteContactSettingString(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_BmpDown"),Buttons[butpos].UserDefinedbmDown);
+ };
+ if (Buttons[butpos].UserDefinedbmUp!=NULL){DBWriteContactSettingString(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_BmpUp"),Buttons[butpos].UserDefinedbmUp);};
+
+
+ return 0;
+}
+
+int SaveAllButtonsOptions()
+{
+ int i;
+ lockbut();
+ for (i=0;i<nButtonsCount;i++)
+ {
+ DBSaveButtonSettings(i);
+ };
+
+ ulockbut();
+
+ return(0);
+};
+int DBLoadButtonSettings(int butpos)
+{
+ char buf[255];
+ DWORD oldv;
+// char *oldtb;
+
+ //must be locked
+ memset(buf,0,sizeof(buf));
+ //DBWriteContactSettingString(0,CLUIFrameModule,strcat("Name",sadd),Frames[Frameid].name);
+
+ //boolean
+ Buttons[butpos].arrangedpos=DBGetContactSettingWord(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_Position"),MAX_BUTTONS);
+ 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);
+ };
+ Buttons[butpos].UserDefinedbmDown=DBGetString(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_BmpDown"));
+ if ((Buttons[butpos].UserDefinedbmDown!=NULL)&&strlen(Buttons[butpos].UserDefinedbmDown)==0){free(Buttons[butpos].UserDefinedbmDown);Buttons[butpos].UserDefinedbmDown=NULL;};
+
+ Buttons[butpos].UserDefinedbmUp=DBGetString(0,TTB_OPTDIR,AS(buf,Buttons[butpos].name,"_BmpUp"));
+ if ((Buttons[butpos].UserDefinedbmUp!=NULL)&&strlen(Buttons[butpos].UserDefinedbmUp)==0){free(Buttons[butpos].UserDefinedbmUp);Buttons[butpos].UserDefinedbmUp=NULL;};
+ return 0;
+}
+
+
+int ttbOptionsChanged()
+{
+
+ //load options
+ if(TRUE) {
+ DBVARIANT dbv;
+ bkColour=DBGetContactSettingDword(NULL,TTB_OPTDIR,"BkColour",TTBDEFAULT_BKCOLOUR);
+ if(hBmpBackground) {DeleteObject(hBmpBackground); hBmpBackground=NULL;}
+ if(DBGetContactSettingByte(NULL,TTB_OPTDIR,"UseBitmap",TTBDEFAULT_USEBITMAP)) {
+ 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);
+ }
+ {
+ RECT rc;
+ GetClientRect(hwndTopToolBar,&rc);
+ InvalidateRect(hwndTopToolBar,&rc,TRUE);
+ UpdateWindow(hwndTopToolBar);
+ }
+ ArrangeButtons();
+ SetAllBitmaps();
+ SaveAllSeparators();
+ SaveAllButtonsOptions();
+
+ return(0);
+};
+
+INT_PTR TTBRemoveButton(WPARAM wParam,LPARAM lParam)
+{
+ int pos;
+
+ lockbut();
+ pos=idtopos(wParam);
+ 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);
+ ArrangeButtons();
+ ulockbut();
+ OptionsPageRebuild();
+ return(0);
+
+};
+static HBITMAP DrawBorderForBitmap(HBITMAP hb,BOOL up)
+{
+ HBITMAP Border,workbmp;
+ HDC workdc,destdc,srcdc;
+
+ Border=LoadBitmap(hInst,MAKEINTRESOURCE(up?IDB_BORDERUP:IDB_BORDERDN));
+ workdc=GetDC(hwndContactList);
+ destdc=CreateCompatibleDC(workdc);
+ srcdc=CreateCompatibleDC(workdc);
+
+ workbmp=CreateBitmap(BUTTWIDTH,BUTTHEIGHT,1,GetDeviceCaps(workdc,BITSPIXEL),NULL);
+ SelectObject(destdc,workbmp);
+
+ SelectObject(srcdc,Border);
+
+ BitBlt(destdc,0,0,BUTTWIDTH,BUTTHEIGHT,srcdc,0,0,SRCCOPY);
+ SelectObject(srcdc,hb);
+ BitBlt(destdc,1,1,BUTTWIDTH-4,BUTTHEIGHT-4,srcdc,0,0,SRCCOPY);
+
+
+
+ DeleteDC(destdc);
+ DeleteDC(srcdc);
+ ReleaseDC(hwndContactList,workdc);
+ return(workbmp);
+};
+
+static int UpdateToolTip(int bpos)
+{
+ {
+ TOOLINFO ti;
+
+ ZeroMemory(&ti,sizeof(ti));
+ 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));
+ }
+
+};
+
+boolean nameexists(const char *name)
+{
+ //must be locked
+ int i;
+
+ for (i=0;i<nButtonsCount;i++)
+ {
+ if (strcmp(Buttons[i].name,name)==0){return(TRUE);};
+ };
+ return(FALSE);
+
+
+};
+
+HICON LoadIconFromLibrary(char *SectName,char *Name,char *Description,HICON hIcon,boolean RegisterIt,boolean *RegistredOk)
+{
+ SKINICONDESC sid={0};
+ int retval;
+
+ //if (hIcon==NULL) return hIcon;
+ if(RegistredOk) *RegistredOk=FALSE;
+
+ if (Name!=NULL&&strlen(Name)!=0)
+ {
+ char iconame[256];
+
+ _snprintf(iconame,sizeof(iconame),"toptoolbar_%s",Name);
+ if(ServiceExists(MS_SKIN2_ADDICON))
+ {
+
+ if (RegisterIt)
+ {
+
+ memset(&sid,0,sizeof(sid));
+ sid.cbSize = sizeof(sid);
+ sid.pszSection = Translate(SectName);
+ sid.pszName=iconame;
+ sid.pszDefaultFile=NULL;
+ sid.pszDescription=Description;
+ sid.hDefaultIcon=hIcon;
+
+ retval=CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+
+ if(RegistredOk) *RegistredOk=TRUE;
+ };
+ return ((HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)iconame));
+ }
+ };
+
+ return hIcon;
+}
+
+
+INT_PTR TTBAddButton(WPARAM wParam,LPARAM lParam)
+{
+ int i,retval;
+ TTBButtonV2 but;
+ {
+ char readbuf[256];
+ sprintf(readbuf,"(%08x)Try Adding TTB Button: wparam:%x\r\n",wParam,wParam);
+ //OutputDebugStringMy(readbuf);
+ }
+
+ if (wParam==0){return(-1);};
+ if (hwndContactList==0){hwndContactList=(HWND)CallService(MS_CLUI_GETHWND,0,0);};
+ if (hwndContactList==0)
+ {
+ //oops clui even now not loaded...sorry no buttons available
+ return(-1);
+ }
+ lockbut();
+ if (nButtonsCount==MAX_BUTTONS){return(-1);};
+
+
+ i=nButtonsCount;
+ memset(&but,0,sizeof(but));
+
+ //but=*((TTBButton*)wParam);
+ if (((TTBButton*)wParam)->cbSize==sizeof(TTBButton))
+ {
+ //(TTBButton)but=*((TTBButton*)wParam);
+ memcpy(&but,(void *)wParam,sizeof(TTBButton));
+ }
+ if (((TTBButton*)wParam)->cbSize==sizeof(TTBButtonV2))
+ {
+ memcpy(&but,(void *)wParam,sizeof(TTBButtonV2));
+ }
+
+ if ( (but.name==NULL) || nameexists(but.name)){return(-1);};
+
+ Buttons[i].id=nextButtonId++;
+ Buttons[i].hbBitmapDown=but.hbBitmapDown;
+ Buttons[i].hbBitmapUp=but.hbBitmapUp;
+ Buttons[i].hbDefBitmapDown=but.hbBitmapDown;
+ Buttons[i].hbDefBitmapUp =but.hbBitmapUp;
+
+ if(but.pszServiceDown!=NULL) Buttons[i].pszServiceDown=strdup(but.pszServiceDown);
+ if(but.pszServiceUp!=NULL) Buttons[i].pszServiceUp=strdup(but.pszServiceUp);
+ Buttons[i].name=strdup(but.name);
+
+ Buttons[i].dwFlags=but.dwFlags;
+
+ if (Buttons[i].dwFlags&TTBBF_DRAWBORDER)
+ {
+ Buttons[i].hbWBordBitmapDown=DrawBorderForBitmap(Buttons[i].hbBitmapDown,FALSE);
+ Buttons[i].hbWBordBitmapUp=DrawBorderForBitmap(Buttons[i].hbBitmapUp,TRUE);
+ };
+
+ Buttons[i].wParamUp=but.wParamUp;
+ Buttons[i].lParamUp=but.lParamUp;
+ Buttons[i].wParamDown=but.wParamDown;
+ Buttons[i].lParamDown=but.lParamDown;
+
+ Buttons[i].dwFlags=but.dwFlags;
+
+ Buttons[i].bPushed=(but.dwFlags&TTBBF_PUSHED)?TRUE:FALSE;
+
+ CreateOneWindow(i);
+
+ Buttons[i].hIconUp =but.hIconUp ;
+ Buttons[i].hIconDn =but.hIconDn ;
+
+
+ if (UseIcoLib&&(!(Buttons[i].dwFlags&TTBBF_ISSEPARATOR)))
+ {
+ char buf[256];
+ sprintf(buf,"%s_up",Buttons[i].name);
+ Buttons[i].hIconUp=LoadIconFromLibrary("TopToolBar",buf,buf,but.hIconDn,TRUE,NULL);
+ sprintf(buf,"%s_dn",Buttons[i].name);
+ Buttons[i].hIconDn=LoadIconFromLibrary("TopToolBar",buf,buf,but.hIconUp,TRUE,NULL);
+
+ }
+
+
+ //WS_EX_TRANSPARENT
+ //SetWindowLong(Buttons[i].hwnd,GWL_EXSTYLE,WS_EX_TRANSPARENT);
+
+
+ Buttons[i].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(Buttons[i].hwndTip, HWND_TOPMOST,0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ {
+ TOOLINFO ti;
+ int res;
+
+ ZeroMemory(&ti,sizeof(ti));
+ ti.cbSize=sizeof(ti);
+ ti.lpszText="";
+ ti.hinst=hInst;
+ ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS ;
+ ti.uId=(UINT_PTR)Buttons[i].hwnd;
+ res=SendMessage(Buttons[i].hwndTip,TTM_ADDTOOL,0,(LPARAM)&ti);
+ }
+
+ SendMessage(Buttons[i].hwndTip,TTM_ACTIVATE,(WPARAM)(Buttons[i].dwFlags&TTBBF_SHOWTOOLTIP)?TRUE:FALSE,0);
+
+ SetWindowLong(Buttons[i].hwnd,GWLP_USERDATA,Buttons[i].id);
+
+ //lastxpos+=BUTTWIDTH+2;
+
+ {
+ //char readbuf[256];
+ //sprintf(readbuf,"(%08x)Adding TTB Button:%s (%08x) id(%d),current buttons count %d\r\n",wParam,Buttons[i].name,Buttons[i].dwFlags,Buttons[i].id,nButtonsCount);
+ //OutputDebugStringMy(readbuf);
+ }
+
+
+ nButtonsCount++;
+
+ retval=Buttons[i].id;
+ DBLoadButtonSettings(i);
+ applyuserbitmaps(i);
+
+ SetButtBitmap(i);
+ ulockbut();
+ ArrangeButtons();
+ OptionsPageRebuild();
+
+ {
+ //char readbuf[256];
+ //sprintf(readbuf,"(%08x)Added TTB Button:%s (%08x) id(%d),current buttons count %d, All Done\r\n",wParam,Buttons[i].name,Buttons[i].dwFlags,Buttons[i].id,nButtonsCount);
+ //OutputDebugStringMy(readbuf);
+ }
+
+ return(retval);
+};
+
+/*
+//wparam=*TTBButton;
+int TTBAddButton(WPARAM wParam,LPARAM lParam)
+{
+ int i,retval;
+ TTBButton but;
+
+ if (wParam==NULL){return(-1);};
+ if (hwndContactList==0){hwndContactList=CallService(MS_CLUI_GETHWND,0,0);};
+ if (hwndContactList==0)
+ {
+ //oops clui even now not loaded...sorry no buttons available
+ return(-1);
+ }
+ lockbut();
+ if (nButtonsCount==MAX_BUTTONS){return(-1);};
+
+
+ i=nButtonsCount;
+ but=*((TTBButton*)wParam);
+ if (but.cbSize!=sizeof(but)){return(-1);};
+ if ( (but.name==NULL) || nameexists(but.name)){return(-1);};
+
+ Buttons[i].id=nextButtonId++;
+ Buttons[i].hbBitmapDown=but.hbBitmapDown;
+ Buttons[i].hbBitmapUp=but.hbBitmapUp;
+ Buttons[i].hbDefBitmapDown=but.hbBitmapDown;
+ Buttons[i].hbDefBitmapUp =but.hbBitmapUp;
+
+ if(but.pszServiceDown!=NULL) Buttons[i].pszServiceDown=strdup(but.pszServiceDown);
+ if(but.pszServiceUp!=NULL) Buttons[i].pszServiceUp=strdup(but.pszServiceUp);
+ Buttons[i].name=strdup(but.name);
+
+ Buttons[i].dwFlags=but.dwFlags;
+
+ if (Buttons[i].dwFlags&TTBBF_DRAWBORDER)
+ {
+ Buttons[i].hbWBordBitmapDown=DrawBorderForBitmap(Buttons[i].hbBitmapDown,FALSE);
+ Buttons[i].hbWBordBitmapUp=DrawBorderForBitmap(Buttons[i].hbBitmapUp,TRUE);
+ };
+
+ Buttons[i].wParamUp=but.wParamUp;
+ Buttons[i].lParamUp=but.lParamUp;
+ Buttons[i].wParamDown=but.wParamDown;
+ Buttons[i].lParamDown=but.lParamDown;
+
+ Buttons[i].dwFlags=but.dwFlags;
+
+ Buttons[i].bPushed=(but.dwFlags&TTBBF_PUSHED)?TRUE:FALSE;
+
+ CreateOneWindow(i);
+
+ if (UseIcoLib&&(!(Buttons[i].dwFlags&TTBBF_ISSEPARATOR)))
+ {
+ char buf[256];
+ sprintf(buf,"%s_up",Buttons[i].name);
+ Buttons[i].hIconUp=LoadIconFromLibrary("TopToolBar",buf,buf,NULL,TRUE,NULL);
+ sprintf(buf,"%s_dn",Buttons[i].name);
+ Buttons[i].hIconDn=LoadIconFromLibrary("TopToolBar",buf,buf,NULL,TRUE,NULL);
+
+ }
+
+
+ //WS_EX_TRANSPARENT
+ //SetWindowLong(Buttons[i].hwnd,GWL_EXSTYLE,WS_EX_TRANSPARENT);
+
+
+ Buttons[i].hwndTip
+ =CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
+ WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ hwndTopToolBar, NULL, hInst,
+ NULL);
+
+SetWindowPos(Buttons[i].hwndTip, HWND_TOPMOST,0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ {
+ TOOLINFO ti;
+ int res;
+
+ ZeroMemory(&ti,sizeof(ti));
+ ti.cbSize=sizeof(ti);
+ ti.lpszText="";
+ ti.hinst=hInst;
+ ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS ;
+ ti.uId=Buttons[i].hwnd;
+ res=SendMessage(Buttons[i].hwndTip,TTM_ADDTOOL,0,&ti);
+ }
+
+ SendMessage(Buttons[i].hwndTip,TTM_ACTIVATE,(WPARAM)(Buttons[i].dwFlags&TTBBF_SHOWTOOLTIP)?TRUE:FALSE,0);
+
+ SetWindowLong(Buttons[i].hwnd,GWL_USERDATA,Buttons[i].id);
+
+ //lastxpos+=BUTTWIDTH+2;
+
+
+ nButtonsCount++;
+
+ retval=Buttons[i].id;
+ DBLoadButtonSettings(i);
+ applyuserbitmaps(i);
+
+ SetButtBitmap(i);
+ ulockbut();
+ ArrangeButtons();
+ OptionsPageRebuild();
+ return(retval);
+};
+
+*/
+
+int sortfunc(const void *a,const void *b)
+{
+ SortData *sd1,*sd2;
+ sd1=a;
+ sd2=b;
+ if (sd1->arrangeval > sd2->arrangeval){return(1);};
+ if (sd1->arrangeval < sd2->arrangeval){return(-1);};
+ /*if (sd1->arrangeval = sd2->arrangeval)*/{return(0);};
+
+};
+boolean isSep(int i)
+{
+ if (Buttons[i].dwFlags&TTBBF_ISSEPARATOR){return(TRUE);}
+ return(FALSE);
+};
+int getbutw(i)
+{
+ RECT rc;
+ GetWindowRect(Buttons[i].hwnd,&rc);
+ return(rc.right-rc.left);
+};
+
+int MakeSortArr(boolean vis)
+{
+ int i;
+ int v;
+ v=0;
+ memset(&arrangedbuts,0,sizeof(arrangedbuts));
+ for (i=0;i<nButtonsCount;i++)
+ {
+ if (vis)
+ {
+ if (!(Buttons[i].dwFlags&TTBBF_VISIBLE)){continue;};
+ };
+ arrangedbuts[v].arrangeval=Buttons[i].arrangedpos;
+ arrangedbuts[v].oldpos=i;
+ v++;
+ };
+ if (v>0)
+ {
+ qsort(&(arrangedbuts[0]),v,sizeof(SortData),sortfunc);
+ };
+ return(v);
+
+};
+
+int CreateOneWindow(int ButtonPos)
+{
+ if (DBGetContactSettingByte(0,TTB_OPTDIR,"UseMirandaButtonClass",UseMirandaButtonClassDefaultValue)&& !(Buttons[ButtonPos].dwFlags&TTBBF_ISSEPARATOR))
+ {
+ Buttons[ButtonPos].hwnd=CreateWindow(MYMIRANDABUTTONCLASS,"",BS_PUSHBUTTON|WS_CHILD|WS_TABSTOP|SS_NOTIFY,0,0,BUTTWIDTH,BUTTHEIGHT,hwndTopToolBar,NULL,hInst,0);
+ //"CLCButtonClass"
+ //SS_NOTIFY|
+ //MYMIRANDABUTTONCLASS
+ }else
+ {
+ Buttons[ButtonPos].hwnd=CreateWindow("STATIC","",WS_CHILD|SS_NOTIFY,
+ 0,0,BUTTWIDTH,BUTTHEIGHT,hwndTopToolBar,NULL,hInst,0);
+ };
+ SetWindowLong(Buttons[ButtonPos].hwnd,GWLP_USERDATA,Buttons[ButtonPos].id);
+ if (DBGetContactSettingByte(0,TTB_OPTDIR,"UseFlatButton",1))
+ SendMessage(Buttons[ButtonPos].hwnd,BUTTONSETASFLATBTN,0,0);
+
+ return(0);
+
+}
+int RecreateWindows()
+{
+ int i;
+ lockbut();
+ for (i=0;i<nButtonsCount;i++)
+ {
+ if (Buttons[i].hwnd)
+ {
+ //SendMessage(Buttons[i].hwnd,STM_SETIMAGE,IMAGE_BITMAP,NULL);
+ //SendMessage(Buttons[i].hwnd,BM_SETIMAGE,IMAGE_BITMAP,NULL);
+
+ DestroyWindow(Buttons[i].hwnd);
+ Buttons[i].hwnd=NULL;
+ CreateOneWindow(i);
+ }
+ }
+
+ ulockbut();
+ SetAllBitmaps();
+ return (0);
+};
+
+int ArrangeButtons()
+{
+ int i,totwidth,visbut;
+ RECT winrc;
+ int newheight,cnt,perline;
+ int v;
+
+ if (StopArrange==TRUE) return(0);
+
+ BUTTHEIGHT=DBGetContactSettingByte(0,TTB_OPTDIR,"BUTTHEIGHT",16);
+ BUTTWIDTH=DBGetContactSettingByte(0,TTB_OPTDIR,"BUTTWIDTH",20);
+
+
+
+ lockbut();
+ lastxpos=1;
+
+ {
+ //sorting stuff
+
+ v=MakeSortArr(TRUE);
+ if (v>0)
+ {
+ for (i=0;i<nButtonsCount;i++)
+ {
+ //SetWindowPos(Buttons[i].hwnd,0,i*(-BUTTWIDTH),-BUTTWIDTH,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW);
+
+
+ if (!(Buttons[i].dwFlags&TTBBF_VISIBLE)){
+ ShowWindow(Buttons[i].hwnd,SW_HIDE);};
+
+ };
+ GetClientRect(hwndTopToolBar,&winrc);
+ winrc.left=winrc.right-winrc.left;
+ winrc.top=winrc.bottom-winrc.top;
+
+ totwidth=1;
+ visbut=0;
+ for (i=0;i<v;i++)
+ {
+ if (!(Buttons[arrangedbuts[i].oldpos].dwFlags&TTBBF_VISIBLE)) continue;
+ totwidth+=BUTTWIDTH+1;
+ visbut++;
+ };
+ //if need wraping
+ if (winrc.left==0){return(0);};
+ {
+
+ perline=winrc.left/(BUTTWIDTH+1);
+ if (perline==0){perline=1;};
+
+ cnt=(visbut)/perline;
+ if (cnt*perline<visbut){cnt++;};
+ newheight=1+((cnt))*(BUTTHEIGHT+2);
+ //if (newheight!=winrc.top)
+ {
+ //CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_HEIGHT,hFrameTopWindow),newheight);
+ };
+ };
+
+ lastypos=1;
+ lastxpos=1;
+ newheight=BUTTHEIGHT+1;
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_HEIGHT,hFrameTopWindow),BUTTHEIGHT+2);
+ for (i=0;i<v;i++)
+ {
+ int w1,w2,x;
+ //Buttons[arrangedbuts[i].oldpos].arrangedpos=i;
+ if (!(Buttons[arrangedbuts[i].oldpos].dwFlags&TTBBF_VISIBLE)){
+ ShowWindow(Buttons[arrangedbuts[i].oldpos].hwnd,SW_HIDE);continue;};
+
+
+// TTBBF_ISSEPARATOR
+ x=SWP_NOZORDER|SWP_SHOWWINDOW;
+ if (Buttons[arrangedbuts[i].oldpos].dwFlags&TTBBF_ISSEPARATOR) {x=SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW;};
+ SetWindowPos(Buttons[arrangedbuts[i].oldpos].hwnd,0,lastxpos,lastypos,BUTTWIDTH,BUTTHEIGHT,x);
+ InvalidateRect(Buttons[arrangedbuts[i].oldpos].hwnd,NULL,TRUE);
+ //RedrawWindow(Buttons[arrangedbuts[i].oldpos].hwnd,NULL,NULL,RDW_UPDATENOW|RDW_ALLCHILDREN|RDW_ERASE|RDW_INVALIDATE);
+ //UpdateWindow(Buttons[arrangedbuts[i].oldpos].hwnd);
+
+ //lastxpos+=BUTTWIDTH+1;
+ if (i==v-1){break;};
+ if (!(Buttons[arrangedbuts[i+1].oldpos].dwFlags&TTBBF_VISIBLE)){continue;};
+
+ w1=getbutw(arrangedbuts[i+1].oldpos);
+ w2=getbutw(arrangedbuts[i].oldpos);
+ 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;
+ };
+ }
+ else
+ {
+ lastxpos+=(isSep(arrangedbuts[i].oldpos))?(SEPWIDTH+2):(BUTTWIDTH+1);
+ if (isSep(arrangedbuts[i+1].oldpos))
+ {
+ lastxpos+=1;
+ };
+
+
+
+ };
+
+ };
+ };
+
+ }
+ v=MakeSortArr(FALSE);
+ ulockbut();
+
+ //RedrawWindow(hwndTopToolBar,NULL,NULL,RDW_UPDATENOW|RDW_ALLCHILDREN|RDW_ERASE|RDW_INVALIDATE);
+ //UpdateWindow(hwndTopToolBar);
+ if (newheight!=winrc.top)
+ {
+ //SendMessage(GetParent(hwndTopToolBar),WM_SIZE,0,0);
+ };
+
+ return (1);
+
+};
+
+
+int applyuserbitmaps(int pos)
+{
+int t=IMAGE_BITMAP;
+ Buttons[pos].hbBitmapDown=Buttons[pos].hbDefBitmapDown;
+Buttons[pos].hbBitmapUp=Buttons[pos].hbDefBitmapUp;
+if (Buttons[pos].UserDefinedbmDown!=NULL)
+{
+ if (strstr(Buttons[pos].UserDefinedbmDown,".ico")) {t=IMAGE_ICON;};
+ Buttons[pos].hbBitmapDown=LoadImage(0,Buttons[pos].UserDefinedbmDown,t,0,0,LR_LOADFROMFILE);
+ //Buttons[pos].hbBitmapDown=CopyImage(Buttons[pos].hbBitmapDown,t,0,0,LR_CREATEDIBSECTION);
+};
+
+if (Buttons[pos].UserDefinedbmUp!=NULL)
+{
+ if (strstr(Buttons[pos].UserDefinedbmUp,".ico")) {t=IMAGE_ICON;};
+ Buttons[pos].hbBitmapUp=LoadImage(0,Buttons[pos].UserDefinedbmUp,t,0,0,LR_LOADFROMFILE);
+};
+
+
+return(0);
+};
+
+int SetAllBitmaps()
+{
+ int i;
+
+ lockbut();
+ for (i=0;i<nButtonsCount;i++)
+ {
+ applyuserbitmaps(i);
+ SetButtBitmap(i);
+ };
+ ulockbut();
+ return(0);
+};
+int SetButtBitmap(int pos)
+{
+int t=IMAGE_BITMAP;
+char *curname;
+int curstyle;
+
+
+
+
+curname=(Buttons[pos].bPushed)?(Buttons[pos].UserDefinedbmDown):(Buttons[pos].UserDefinedbmUp);
+
+curstyle=GetWindowLong(Buttons[pos].hwnd,GWL_STYLE);
+curstyle&=(~SS_BITMAP);
+curstyle&=(~SS_ICON);
+
+/*
+if (UseIcoLib&&DBGetContactSettingByte(0,TTB_OPTDIR,"UseMirandaButtonClass",0)&& !(Buttons[pos].dwFlags&TTBBF_ISSEPARATOR))
+{
+
+ //SendMessage(Buttons[pos].hwnd,BM_SETIMAGE,IMAGE_ICON,(Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp));
+ return 0;
+}
+*/
+
+if (!UseIcoLib||(Buttons[pos].dwFlags&TTBBF_ISSEPARATOR))
+{
+ if (curname!=NULL)
+ {
+ if (strstr(curname,".ico")) {t=IMAGE_ICON;};
+
+ (t==IMAGE_ICON||UseIcoLib)?(curstyle|=SS_ICON):(curstyle|=SS_BITMAP);
+ SetWindowLong(Buttons[pos].hwnd,GWL_STYLE,curstyle);
+ }else
+ {
+ SetWindowLong(Buttons[pos].hwnd,GWL_STYLE,curstyle|(Buttons[pos].hbBitmapDown==NULL?SS_ICON:SS_BITMAP));
+ }
+} else
+{
+ if (GetWindowLong(Buttons[pos].hwnd,GWL_STYLE)&SS_ICON)
+ {
+ SetWindowLong(Buttons[pos].hwnd,GWL_STYLE,curstyle|SS_ICON);
+ }
+}
+
+
+
+if (!UseIcoLib||(Buttons[pos].dwFlags&TTBBF_ISSEPARATOR))
+{
+ if(!(Buttons[pos].dwFlags&TTBBF_DRAWBORDER))
+ {
+ if (Buttons[pos].hbBitmapDown==NULL)
+ {
+ t=IMAGE_ICON;
+ SendMessage(Buttons[pos].hwnd,STM_SETIMAGE,t,(LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
+ SendMessage(Buttons[pos].hwnd,BM_SETIMAGE,t,(LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
+ }else
+ {
+ SendMessage(Buttons[pos].hwnd,STM_SETIMAGE,t,(LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hbBitmapDown):(Buttons[pos].hbBitmapUp)));
+ SendMessage(Buttons[pos].hwnd,BM_SETIMAGE,t,(LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hbBitmapDown):(Buttons[pos].hbBitmapUp)));
+ }
+
+
+ }
+ else
+ {
+ SendMessage(Buttons[pos].hwnd,STM_SETIMAGE,t,(LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hbWBordBitmapDown):(Buttons[pos].hbWBordBitmapUp)));
+ }
+}else
+{
+ SendMessage(Buttons[pos].hwnd,BM_SETIMAGE,IMAGE_ICON,(LPARAM)((Buttons[pos].bPushed)?(Buttons[pos].hIconDn):(Buttons[pos].hIconUp)));
+}
+
+return(0);
+};
+
+//wparam=hTTBButton
+//lparam=state
+INT_PTR TTBSetState(WPARAM wParam,LPARAM lParam)
+{
+ int pos;
+
+ lockbut();
+ pos=idtopos(wParam);
+ if (pos<0||pos>=nButtonsCount){ulockbut();;return(-1);};
+
+ Buttons[pos].bPushed=(lParam&TTBST_PUSHED)?TRUE:FALSE;
+ Buttons[pos].bPushed=(lParam&TTBST_RELEASED)?FALSE:TRUE;
+ SetButtBitmap(pos);
+ ulockbut();
+ return(0);
+};
+
+//wparam=hTTBButton
+//lparam=0
+//return=state
+INT_PTR TTBGetState(WPARAM wParam,LPARAM lParam)
+{
+ int pos,retval;
+
+ lockbut();
+ pos=idtopos(wParam);
+ if (pos<0||pos>=nButtonsCount){ulockbut();return(-1);};
+
+ retval=(Buttons[pos].bPushed==TRUE)?TTBST_PUSHED:TTBST_RELEASED;
+ ulockbut();
+ return(retval);
+};
+
+INT_PTR TTBGetOptions(WPARAM wParam,LPARAM lParam)
+{
+ int pos,retval;
+
+ lockbut();
+ pos=idtopos(HIWORD(wParam));
+ if (pos<0||pos>=nButtonsCount){ulockbut();return(-1);};
+
+ switch(LOWORD(wParam))
+ {
+ case TTBO_FLAGS:
+
+ retval=Buttons[pos].dwFlags&(!TTBBF_PUSHED);
+ if (Buttons[pos].bPushed){retval|=TTBBF_PUSHED;};
+ break;
+
+ case TTBO_POS:
+ retval=(int)pos;
+ break;
+
+ case TTBO_TIPNAME:
+ retval=(int)Buttons[pos].tooltip;
+ break;
+
+ case TTBO_ALLDATA:
+ {
+
+ lpTTBButton lpTTB=lParam;
+
+ if (lParam==0){break;};
+ if (lpTTB->cbSize!=sizeof(TTBButton)){break;};
+ lpTTB->dwFlags=Buttons[pos].dwFlags&(!TTBBF_PUSHED);
+ if (Buttons[pos].bPushed){lpTTB->dwFlags|=TTBBF_PUSHED;};
+
+ lpTTB->hbBitmapDown=Buttons[pos].hbBitmapDown;
+ lpTTB->hbBitmapUp=Buttons[pos].hbBitmapUp;
+ lpTTB->lParamUp=Buttons[pos].lParamUp;
+ lpTTB->wParamUp=Buttons[pos].wParamUp;
+ lpTTB->lParamDown=Buttons[pos].lParamDown;
+ lpTTB->wParamDown=Buttons[pos].wParamDown;
+
+ lpTTB->pszServiceDown=_strdup(Buttons[pos].pszServiceDown);
+ lpTTB->pszServiceUp=_strdup(Buttons[pos].pszServiceUp);
+
+ retval=lpTTB;
+ break;
+ }
+
+ default:
+ retval=-1;
+ break;
+ }
+
+
+ ulockbut();
+ return(retval);
+
+};
+
+
+INT_PTR TTBSetOptions(WPARAM wParam,LPARAM lParam)
+{
+ int pos,retval;
+
+ lockbut();
+ pos=idtopos(HIWORD(wParam));
+ if (pos<0||pos>=nButtonsCount){ulockbut();return(-1);};
+
+ switch(LOWORD(wParam))
+ {
+ case TTBO_FLAGS:
+ //retval=Buttons[i].dwFlags;
+ if (Buttons[pos].dwFlags==lParam){break;};
+ Buttons[pos].dwFlags=lParam;
+ Buttons[pos].bPushed=(Buttons[pos].dwFlags&TTBBF_PUSHED)?TRUE:FALSE;
+ if (Buttons[pos].dwFlags&TTBBF_DRAWBORDER)
+ {
+ Buttons[pos].hbWBordBitmapDown=DrawBorderForBitmap(Buttons[pos].hbBitmapDown,FALSE);
+ Buttons[pos].hbWBordBitmapUp=DrawBorderForBitmap(Buttons[pos].hbBitmapUp,TRUE);
+ };
+
+ SetButtBitmap(pos);
+ SendMessage(Buttons[pos].hwndTip,TTM_ACTIVATE,(WPARAM)(Buttons[pos].dwFlags&TTBBF_SHOWTOOLTIP)?TRUE:FALSE,0);
+ retval=1;
+ break;
+
+ case TTBO_POS:
+ {
+ TopButtonInt tempttb;
+
+ if (lParam<0||lParam>=nButtonsCount){break;};
+ tempttb=Buttons[lParam];
+ Buttons[lParam]=Buttons[pos];
+ Buttons[pos]=tempttb;
+
+ ArrangeButtons();
+
+ retval=(int)1;
+ break;
+ }
+
+ case TTBO_TIPNAME:
+ if (lParam==0){break;};
+ if (Buttons[pos].tooltip!=NULL){free(Buttons[pos].tooltip);};
+ Buttons[pos].tooltip=_strdup((LPCSTR)lParam);
+ UpdateToolTip(pos);
+ retval=1;
+ break;
+
+ case TTBO_ALLDATA:
+ {
+
+ lpTTBButton lpTTB=lParam;
+
+ if (lParam==0){break;};
+ if (lpTTB->cbSize!=sizeof(TTBButton)){break;};
+ Buttons[pos].dwFlags=lpTTB->dwFlags;
+ Buttons[pos].hbBitmapDown=lpTTB->hbBitmapDown;
+ Buttons[pos].hbBitmapUp=lpTTB->hbBitmapUp;
+ Buttons[pos].lParamUp=lpTTB->lParamUp;
+ Buttons[pos].wParamUp=lpTTB->wParamUp;
+ 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);};
+
+ Buttons[pos].pszServiceDown=_strdup(lpTTB->pszServiceDown);
+ Buttons[pos].pszServiceUp=_strdup(lpTTB->pszServiceUp);
+
+ if (Buttons[pos].dwFlags&TTBBF_DRAWBORDER)
+ {
+ Buttons[pos].hbWBordBitmapDown=DrawBorderForBitmap(Buttons[pos].hbBitmapDown,FALSE);
+ Buttons[pos].hbWBordBitmapUp=DrawBorderForBitmap(Buttons[pos].hbBitmapUp,TRUE);
+ };
+
+
+ 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);
+ ArrangeButtons();
+ retval=1;
+ break;
+ }
+
+ default:
+ retval=-1;
+ break;
+ }
+
+
+ ulockbut();
+ return(retval);
+
+};
+
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
+{
+ hInst=hinstDLL;
+ return TRUE;
+}
+
+LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_CREATE:
+ {
+ {
+ hwndTopToolBar=hwnd;
+ }
+
+ return(FALSE);
+ };
+
+ case WM_MOVE:
+ {
+ //RedrawWindow(hwnd,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
+ return(0);
+ };
+
+ case WM_WINDOWPOSCHANGING:
+ case WM_SIZE:
+ {
+ ArrangeButtons();
+
+ //RedrawWindow(hwnd,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
+ return(0);
+ };
+
+ //InvalidateRect(hwnd,NULL,TRUE);
+ //ArrangeButtons();
+ case WM_PAINT:
+ {
+ HDC hdcMem,hdc;
+ RECT clRect,*rcPaint;
+ int yScroll=0;
+ int y;
+ PAINTSTRUCT paintst;
+ HBITMAP hBmpOsb,hOldBmp;
+ DWORD style=GetWindowLong(hwnd,GWL_STYLE);
+ int grey=0;
+ HBRUSH hBrushAlternateGrey=NULL;
+
+ InvalidateRect(hwnd,0,FALSE);
+
+ hdc=BeginPaint(hwnd,&paintst);
+ rcPaint=&(paintst.rcPaint);
+
+ GetClientRect(hwnd,&clRect);
+ if(rcPaint==NULL) rcPaint=&clRect;
+ y=-yScroll;
+ hdcMem=CreateCompatibleDC(hdc);
+ hBmpOsb=CreateBitmap(clRect.right,clRect.bottom,1,GetDeviceCaps(hdc,BITSPIXEL),NULL);
+ hOldBmp=SelectObject(hdcMem,hBmpOsb);
+ SetBkMode(hdcMem,TRANSPARENT);
+ { HBRUSH hBrush,hoBrush;
+
+ hBrush=CreateSolidBrush(bkColour);
+ hoBrush=(HBRUSH)SelectObject(hdcMem,hBrush);
+ FillRect(hdcMem,rcPaint,hBrush);
+ SelectObject(hdcMem,hoBrush);
+ DeleteObject(hBrush);
+ if(hBmpBackground) {
+ BITMAP bmp;
+ HDC hdcBmp;
+ int x,y;
+ int maxx,maxy;
+ int destw,desth;
+
+ GetObject(hBmpBackground,sizeof(bmp),&bmp);
+ hdcBmp=CreateCompatibleDC(hdcMem);
+ SelectObject(hdcBmp,hBmpBackground);
+ y=backgroundBmpUse&CLBF_SCROLL?-yScroll:0;
+ maxx=backgroundBmpUse&CLBF_TILEH?clRect.right:1;
+ maxy=backgroundBmpUse&CLBF_TILEV?maxy=rcPaint->bottom:y+1;
+ switch(backgroundBmpUse&CLBM_TYPE) {
+ case CLB_STRETCH:
+ if(backgroundBmpUse&CLBF_PROPORTIONAL) {
+ if(clRect.right*bmp.bmHeight<clRect.bottom*bmp.bmWidth) {
+ desth=clRect.bottom;
+ destw=desth*bmp.bmWidth/bmp.bmHeight;
+ }
+ else {
+ destw=clRect.right;
+ desth=destw*bmp.bmHeight/bmp.bmWidth;
+ }
+ }
+ else {
+ destw=clRect.right;
+ desth=clRect.bottom;
+ }
+ break;
+ case CLB_STRETCHH:
+ if(backgroundBmpUse&CLBF_PROPORTIONAL) {
+ destw=clRect.right;
+ desth=destw*bmp.bmHeight/bmp.bmWidth;
+ if (backgroundBmpUse&CLBF_TILEVTOROWHEIGHT)
+ {
+ desth=BUTTHEIGHT+2;
+ }
+
+ }
+ else {
+ destw=clRect.right;
+ desth=bmp.bmHeight;
+ }
+ break;
+ case CLB_STRETCHV:
+ if(backgroundBmpUse&CLBF_PROPORTIONAL) {
+ desth=clRect.bottom;
+ destw=desth*bmp.bmWidth/bmp.bmHeight;
+ }
+ else {
+ destw=bmp.bmWidth;
+ desth=clRect.bottom;
+ }
+ break;
+ default: //clb_topleft
+ destw=bmp.bmWidth;
+ desth=bmp.bmHeight;
+ if (backgroundBmpUse&CLBF_TILEVTOROWHEIGHT)
+ {
+ desth=BUTTHEIGHT+2;
+ }
+
+ break;
+ }
+ for(;y<maxy;y+=desth) {
+ if(y<rcPaint->top-desth) continue;
+ for(x=0;x<maxx;x+=destw)
+ StretchBlt(hdcMem,x,y,destw,desth,hdcBmp,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
+ }
+ DeleteDC(hdcBmp);
+ }
+ }
+ BitBlt(hdc,rcPaint->left,rcPaint->top,rcPaint->right-rcPaint->left,rcPaint->bottom-rcPaint->top,hdcMem,rcPaint->left,rcPaint->top,SRCCOPY);
+ SelectObject(hdcMem,hOldBmp);
+ DeleteDC(hdcMem);
+ DeleteObject(hBmpOsb);
+ paintst.fErase=FALSE;
+ EndPaint(hwnd,&paintst);
+
+
+ return(0);
+ };
+ case WM_LBUTTONDOWN:
+ {
+ if (DBGetContactSettingByte(NULL,"CLUI","ClientAreaDrag",0)) {
+ POINT pt;
+ //pt=nm->pt;
+ GetCursorPos(&pt);
+ return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION,MAKELPARAM(pt.x,pt.y));
+ }
+ return(0);
+ };
+ case WM_NOTIFY:
+ {
+ int id=wParam;
+ LPNMHDR lpnm=(LPNMHDR)lParam;
+ switch(lpnm->code)
+ {
+ case 1:{;};
+ };
+
+ return(0);
+ };
+ case WM_COMMAND:
+ {
+ if ((HIWORD(wParam)==STN_CLICKED|| HIWORD(wParam)==STN_DBLCLK))
+ {
+ int id=GetWindowLong((HWND)lParam,GWLP_USERDATA);
+ int pos;
+
+ if (id==0){break;};
+ lockbut();
+ pos=idtopos(id);
+ if(isSep(pos)){ulockbut();return(0);};
+ if (Buttons[pos].bPushed)
+ {//Dn -> Up
+ Buttons[pos].bPushed=!Buttons[pos].bPushed;
+ SetButtBitmap(pos);
+
+ if(Buttons[pos].pszServiceUp!=NULL) CallService(Buttons[pos].pszServiceUp,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);
+ };
+ ulockbut();
+ };
+ break;
+ };
+
+ default:
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+
+ };
+ return(TRUE);
+};
+
+int addTopToolBarWindow(HWND parent)
+{
+ WNDCLASS wndclass;
+
+ CLISTFrame Frame;
+ int retval;
+ HWND pluginwind;
+ char pluginname[]="TopToolBar";
+
+ wndclass.style = 0;
+ wndclass.lpfnWndProc = TopToolBarProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hInst;
+ wndclass.hIcon = NULL;
+ wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);//NULL;//(HBRUSH)(COLOR_3DFACE+1);
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = pluginname;
+ RegisterClass(&wndclass);
+ pluginwind=CreateWindow(pluginname,pluginname,
+ WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
+ 0,0,0,0,parent,NULL,hInst,NULL);
+
+ //font=SendMessage(parent,WM_GETFONT,0,0);
+ //SendMessage(pluginwind,WM_SETFONT,font,0);
+ ttbOptionsChanged();
+ //
+ memset(&Frame,0,sizeof(Frame));
+ Frame.name=(char *)malloc(255);
+ memset(Frame.name,0,255);
+ memcpy(Frame.name,pluginname,sizeof(pluginname));
+ Frame.cbSize=sizeof(Frame);
+ Frame.hWnd=pluginwind;
+ Frame.align=alTop;
+ Frame.Flags=F_VISIBLE|F_NOBORDER|F_LOCKED;
+ Frame.height=18;
+
+ retval=CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,0);
+ free(Frame.name);
+
+
+ return(retval);
+
+
+};
+
+VOID CALLBACK TimerProc(
+ HWND hwnd, // handle to window
+ UINT uMsg, // WM_TIMER message
+ UINT_PTR idEvent, // timer identifier
+ DWORD dwTime // current system time
+)
+{
+ KillTimer(0,idEvent);
+ NotifyEventHooks(hHookTTBModuleLoaded, 0,0);
+
+
+};
+
+static INT_PTR OnEventFire(WPARAM wParam,LPARAM lParam) {
+ CallService(MS_SYSTEM_REMOVEWAIT,wParam,0);
+ StopArrange=FALSE;
+ NotifyEventHooks(hHookTTBModuleLoaded, 0,0);
+ return(0);
+};
+
+int OnIconChange(WPARAM wParam,LPARAM lParam) {
+int i;
+ lockbut();
+ for (i=0;i<nButtonsCount;i++)
+ {
+ char buf[256];
+ sprintf(buf,"%s_up",Buttons[i].name);
+ Buttons[i].hIconUp=LoadIconFromLibrary("TopToolBar",buf,buf,Buttons[i].hIconUp,FALSE,NULL);
+ sprintf(buf,"%s_dn",Buttons[i].name);
+ Buttons[i].hIconDn=LoadIconFromLibrary("TopToolBar",buf,buf,Buttons[i].hIconDn,FALSE,NULL);
+ };
+ ulockbut();
+ RecreateWindows();
+ SetAllBitmaps();
+ ArrangeButtons();
+ return(0);
+};
+
+static int OnBGChange(WPARAM wParam,LPARAM lParam) {
+
+ttbOptionsChanged();
+return(0);
+};
+
+
+static int OnmodulesLoad(WPARAM wParam,LPARAM lParam) {
+
+ int ex=0;
+
+ hwndContactList=(HWND)CallService(MS_CLUI_GETHWND,0,0);
+
+ if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ MessageBox(0,"Frames Services not found - plugin disabled.You need MultiWindow plugin.","TopToolBar",0);
+ return(0);
+ ex=1;
+ }
+ if (!ServiceExists(MS_CLUI_GETHWNDTREE)) {
+ MessageBox(0,"MS_CLUI_GETHWNDTREE Service not found - plugin disabled","TopToolBar",0);
+ return(0);
+ ex=1;
+ }
+
+ if (ex==1)
+ {
+ //destroy hook ???
+ return(0);
+ }
+ OptionsOpened=FALSE;
+ CreateServiceFunction(MS_TTB_ADDBUTTON,TTBAddButton);
+ CreateServiceFunction(MS_TTB_REMOVEBUTTON,TTBRemoveButton);
+
+ CreateServiceFunction(MS_TTB_SETBUTTONSTATE,TTBSetState);
+ CreateServiceFunction(MS_TTB_GETBUTTONSTATE,TTBGetState);
+
+ CreateServiceFunction(MS_TTB_GETBUTTONOPTIONS,TTBGetOptions);
+ CreateServiceFunction(MS_TTB_SETBUTTONOPTIONS,TTBSetOptions);
+ CreateServiceFunction(TTB_ADDSEPARATOR,InsertNewFreeSeparator);
+ CreateServiceFunction(TTB_REMOVESEPARATOR,DeleteSeparator);
+
+
+ CreateServiceFunction("TTB_ONSTARTUPFIRE",OnEventFire);
+ UseIcoLib=DBGetContactSettingByte(0,TTB_OPTDIR,"UseIcoLib",UseIcoLibDefaultValue);
+ if (UseIcoLib)
+ {
+ HookEvent(ME_SKIN2_ICONSCHANGED,OnIconChange);
+ }
+
+
+ hFrameTopWindow = addTopToolBarWindow(hwndContactList);
+ LoadInternalButtons(CallService(MS_CLUI_GETHWNDTREE,0,0));
+ SaveAllButtonsOptions();
+
+ LoadAllSeparators();
+ InitLBut();
+
+ StopArrange=FALSE;
+ ArrangeButtons();
+
+ //SetTimer(0,GetTickCount(),1,&TimerProc);
+ {
+ HANDLE hEvent=CreateEvent(NULL,TRUE,TRUE,NULL);//anonymous event
+ if (hEvent!=0)
+ {
+ CallService(MS_SYSTEM_WAITONHANDLE,(WPARAM)hEvent,(LPARAM)"TTB_ONSTARTUPFIRE");
+ };
+ };
+
+ if (ServiceExists(MS_BACKGROUNDCONFIG_REGISTER))
+ {
+ char buf[256];
+ sprintf(buf,"TopToolBar Background/%s",TTB_OPTDIR);
+ CallService(MS_BACKGROUNDCONFIG_REGISTER,(WPARAM)buf,0);
+ HookEvent(ME_BACKGROUNDCONFIG_CHANGED,OnBGChange);
+ };
+
+
+ return(0);
+};
+
+static const MUUID interfaces[] = {MIID_TTB, MIID_LAST};
+
+__declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
+{
+ return interfaces;
+}
+
+__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+int __declspec(dllexport) Load(PLUGINLINK *link)
+{
+ pluginLink=link;
+ mir_getMMI( &mmi );
+ mir_getLP(&pluginInfo);
+
+ InitializeCriticalSection(&csButtonsHook);
+ StopArrange=TRUE;
+ LoadCLCButtonModule();
+ LoadButtonModule();
+
+
+ hModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,OnmodulesLoad);
+ hOptInit=HookEvent(ME_OPT_INITIALISE,TTBOptInit);
+
+
+
+ BUTTHEIGHT=DBGetContactSettingByte(0,TTB_OPTDIR,"BUTTHEIGHT",16);
+ BUTTWIDTH=DBGetContactSettingByte(0,TTB_OPTDIR,"BUTTWIDTH",20);
+ hHookTTBModuleLoaded = CreateHookableEvent(ME_TTB_MODULELOADED);
+
+ return 0;
+}
+
+int __declspec(dllexport) Unload(void)
+{
+ //if (hFrameTopWindow!=NULL){CallService(MS_CLIST_FRAMES_REMOVEFRAME,(WPARAM)hFrameTopWindow,(LPARAM)0);};
+
+
+ SaveAllSeparators();
+ UnInitLBut();
+ UnLoadInternalButtons();
+
+ DeleteCriticalSection(&csButtonsHook);
+ //DestroyServiceFunction();
+ UnhookEvent(hModulesLoaded);
+ UnhookEvent(hOptInit);
+
+ return 0;
+} \ No newline at end of file
diff --git a/plugins/TopToolBar/main.rc b/plugins/TopToolBar/main.rc
new file mode 100644
index 0000000000..235447ddba
--- /dev/null
+++ b/plugins/TopToolBar/main.rc
@@ -0,0 +1,331 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1251)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPT_BUTORDER DIALOGEX 0, 0, 300, 231
+STYLE DS_SETFONT | WS_CHILD
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ GROUPBOX "Buttons Order && Visibility",IDC_STATIC,10,0,150,180
+ CONTROL "Tree1",IDC_BUTTONORDERTREE,"SysTreeView32",TVS_NOTOOLTIPS | WS_BORDER | WS_TABSTOP,20,25,132,100
+ LTEXT "Buttons order:",IDC_STATIC,20,15,132,8
+ CONTROL 268,IDC_BMPUP,"Static",SS_BITMAP | SS_NOTIFY,60,130,13,10
+ CONTROL 268,IDC_BMPDN,"Static",SS_BITMAP | SS_NOTIFY,115,130,13,10,WS_EX_TRANSPARENT
+ LTEXT "Up:",IDC_STATIC1,35,130,12,8
+ LTEXT "Down:",IDC_STATIC2,85,130,22,8
+ PUSHBUTTON "Default",IDC_DEFAULT,55,146,50,14
+ LTEXT "Click on images to select new bitmaps.",IDC_STATIC3,15,165,140,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
+ EDITTEXT IDC_ENAME,195,100,85,14,ES_AUTOHSCROLL
+ LTEXT "Name: ",IDC_LBUTTONNAME,170,100,24,8
+ EDITTEXT IDC_EPATH,195,121,85,14,ES_AUTOHSCROLL
+ LTEXT "Path:",IDC_LBUTTONPATH,170,121,18,8
+ PUSHBUTTON "Set",IDC_LBUTTONSET,205,140,50,14
+ EDITTEXT IDC_IMGDIR,65,190,205,14,ES_AUTOHSCROLL | ES_READONLY
+ GROUPBOX "Separator Button",IDC_STATIC,165,0,130,40
+ GROUPBOX "Launch Button",IDC_STATIC,165,45,130,115
+ PUSHBUTTON "...",IDC_OPENIMGDIR,275,190,14,14
+ CONTROL "Image Directory:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,5,190,55,10
+ LTEXT "Button Height:",IDC_STATIC,11,210,46,8
+ EDITTEXT IDC_BUTTHEIGHT,65,207,24,14,ES_AUTOHSCROLL
+ LTEXT "Button Width: ",IDC_STATIC,99,210,46,8
+ EDITTEXT IDC_BUTTWIDTH,147,208,24,14,ES_AUTOHSCROLL
+ CONTROL "Use Miranda Button Class",IDC_USEMIRANDABUTTON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,185,210,97,10
+ CONTROL "Use Flat Mode",IDC_USEFLAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,220,62,10
+ CONTROL "Use IcoLib (need restart!)",IDC_USEICOLIB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,165,95,10
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPT_BUTORDER, DIALOG
+ BEGIN
+ VERTGUIDE, 8
+ VERTGUIDE, 140
+ VERTGUIDE, 158
+ VERTGUIDE, 290
+ VERTGUIDE, 297
+ BOTTOMMARGIN, 229
+ HORZGUIDE, 17
+ HORZGUIDE, 38
+ HORZGUIDE, 133
+ HORZGUIDE, 138
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Russian resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+#ifdef _WIN32
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_FRAMEPLUG2 DIALOG 0, 0, 211, 11
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN
+FONT 8, "MS Sans Serif"
+BEGIN
+ CONTROL 262,IDC_P2ONLINEBUTT,"Static",SS_BITMAP | SS_NOTIFY | NOT WS_VISIBLE,55,0,13,10
+ CONTROL 269,IDC_P2GROUPBUTT,"Static",SS_BITMAP | SS_NOTIFY | NOT WS_VISIBLE,70,0,13,10
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_FRAMEPLUG2, DIALOG
+ BEGIN
+ RIGHTMARGIN, 197
+ BOTTOMMARGIN, 10
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_TESTBITMAP BITMAP "bmp\\test.bmp"
+IDB_OPTIONS BITMAP "bmp\\options.bmp"
+IDB_SEP BITMAP "bmp\\sep.bmp"
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_SHOWONLINEUP ICON "icos\\Show only Online Users_UP.ico"
+IDI_SHOWONLINEDN ICON "icos\\Show only Online Users_DN.ico"
+IDI_GROUPSUP ICON "icos\\Groups On_Off_UP.ico"
+IDI_GROUPSDN ICON "icos\\Groups On_Off_DN.ico"
+IDI_SOUNDDN ICON "icos\\Sounds Enable_Disable_DN.ico"
+IDI_SOUNDUP ICON "icos\\Sounds Enable_Disable_UP.ico"
+IDI_OPTIONSUP ICON "icos\\Show Options Page_UP.ico"
+IDI_OPTIONSDN ICON "icos\\Show Options Page_DN.ico"
+IDI_MINIMIZEUP ICON "icos\\Minimize Button_UP.ico"
+IDI_MINIMIZEDN ICON "icos\\Minimize Button_DN.ico"
+IDI_FINDADDUP ICON "icos\\Find_Add Contacts_UP.ico"
+IDI_FINDADDDN ICON "icos\\Find_Add Contacts_DN.ico"
+IDI_MIRANDAUP ICON "icos\\Show Main Menu_UP.ico"
+IDI_MIRANDADN ICON "icos\\Show Main Menu_DN.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 0,7,3,1
+ PRODUCTVERSION 0,7,3,1
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "041904b0"
+ BEGIN
+ VALUE "FileDescription", "ToptoolBar adds buttons in top frame for fast access."
+ VALUE "FileVersion", "0.7.3.1"
+ VALUE "InternalName", "TopToolBar"
+ VALUE "LegalCopyright", "© 2003-2008 Bethoven"
+ VALUE "OriginalFilename", "TopToolbar.dll"
+ VALUE "ProductName", "TopToolBar"
+ VALUE "ProductVersion", "0.7.3.1"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x419, 1200
+ END
+END
+
+#endif // Russian resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_NOTICK ICON "icos\\notick.ico"
+IDI_TICK ICON "icos\\notick1.ico"
+#endif // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (Canada) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENC)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPT_TTBBKG DIALOGEX 0, 0, 235, 132
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ GROUPBOX "TopToolBar Background",IDC_STATIC,4,4,227,124
+ LTEXT "Background colour:",IDC_STATIC,12,20,72,8,NOT WS_GROUP
+ CONTROL "",IDC_BKGCOLOUR,"ColourPicker",WS_TABSTOP,84,19,32,10
+ LTEXT "Selection colour:",IDC_STATIC,12,36,72,8,NOT WS_VISIBLE
+ CONTROL "",IDC_SELCOLOUR,"ColourPicker",NOT WS_VISIBLE | WS_TABSTOP,84,35,32,10
+ CONTROL "Use background bitmap",IDC_BITMAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,53,161,10
+ EDITTEXT IDC_FILENAME,22,67,184,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_BROWSE,208,67,15,11
+ CONTROL "Stretch to width",IDC_STRETCHH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,84,100,10
+ CONTROL "Stretch to height",IDC_STRETCHV,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,84,101,10
+ CONTROL "Tile horizontally",IDC_TILEH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,97,100,10
+ CONTROL "Tile vertically",IDC_TILEV,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,97,101,10
+ CONTROL "Scroll with text",IDC_SCROLL,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,22,110,100,10
+ CONTROL "Stretch proportionally",IDC_PROPORTIONAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,110,101,10
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPT_TTBBKG, DIALOG
+ BEGIN
+ LEFTMARGIN, 4
+ RIGHTMARGIN, 231
+ VERTGUIDE, 12
+ VERTGUIDE, 22
+ VERTGUIDE, 122
+ TOPMARGIN, 4
+ BOTTOMMARGIN, 128
+ HORZGUIDE, 24
+ HORZGUIDE, 40
+ HORZGUIDE, 73
+ HORZGUIDE, 89
+ HORZGUIDE, 102
+ HORZGUIDE, 115
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (Canada) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/TopToolBar/resource.h b/plugins/TopToolBar/resource.h
new file mode 100644
index 0000000000..d83b333797
--- /dev/null
+++ b/plugins/TopToolBar/resource.h
@@ -0,0 +1,95 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by main.rc
+//
+#define IDB_SOUNDSUP 103
+#define IDB_SOUNDSDN 104
+#define IDB_BORDERDN 105
+#define IDB_BORDERUP 106
+#define IDB_TESTBITMAP 108
+#define IDB_OPTIONS 109
+#define IDB_CPANELDN 112
+#define IDB_CPANELUP 113
+#define IDB_MENUUP 114
+#define IDB_MENUDN 115
+#define IDB_LAUNCHDN 117
+#define IDB_SEP 118
+#define IDB_LAUNCHUP 119
+#define IDB_MINIMIZEUP 121
+#define IDB_MINIMIZEDN 122
+#define IDB_FINDUSERDN 123
+#define IDB_FINDUSERUP 124
+#define IDI_SHOWONLINEUP 125
+#define IDI_SHOWONLINEDN 126
+#define IDI_GROUPSUP 127
+#define IDI_GROUPSDN 128
+#define IDI_SOUNDDN 129
+#define IDI_SOUNDUP 130
+#define IDI_OPTIONSUP 131
+#define IDI_OPTIONSDN 132
+#define IDI_MINIMIZEUP 133
+#define IDI_MINIMIZEDN 134
+#define IDI_FINDADDUP 135
+#define IDI_FINDADDDN 136
+#define IDI_MIRANDAUP 137
+#define IDI_ICON1 138
+#define IDI_MIRANDADN 138
+#define IDI_NOTICK 205
+#define IDI_TICK 206
+#define IDD_OPT_TTBBKG 230
+#define IDB_ONLINEUP 262
+#define IDD_OPT_INTERNALORDER 262
+#define IDD_OPT_BUTORDER 262
+#define IDB_ONLINEDN 264
+#define IDD_FRAMEPLUG2 265
+#define IDB_GROUPUP 268
+#define IDB_GROUPDN 269
+#define IDC_BMPUP 1000
+#define IDC_BMPDN 1001
+#define IDC_BUTTON1 1002
+#define IDC_DEFAULT 1002
+#define IDC_ADDSEP 1003
+#define IDC_REMOVESEP 1004
+#define IDC_ADDLBUTTON 1005
+#define IDC_DELLBUTTON 1006
+#define IDC_ENAME 1007
+#define IDC_LBUTTONNAME 1008
+#define IDC_EPATH 1009
+#define IDC_LBUTTONPATH 1011
+#define IDC_LBUTTONSET 1012
+#define IDC_IMGDIR 1013
+#define IDC_OPENIMGDIR 1014
+#define IDC_BUTTHEIGHT 1015
+#define IDC_EDIT2 1016
+#define IDC_BUTTWIDTH 1016
+#define IDC_USEMIRANDABUTTON 1017
+#define IDC_USEFLAT 1018
+#define IDC_USEICOLIB 1019
+#define IDC_STATIC1 1020
+#define IDC_STATIC2 1021
+#define IDC_STATIC3 1022
+#define IDC_BROWSE 1184
+#define IDC_BKGCOLOUR 1269
+#define IDC_FILENAME 1271
+#define IDC_SCROLL 1277
+#define IDC_PROPORTIONAL 1278
+#define IDC_SELCOLOUR 1281
+#define IDC_STRETCHH 1298
+#define IDC_STRETCHV 1299
+#define IDC_TILEH 1300
+#define IDC_TILEV 1301
+#define IDC_BITMAP 1363
+#define IDC_P2ONLINEBUTT 1562
+#define IDC_P2GROUPBUTT 1564
+#define IDC_BUTTONORDERTREE 1591
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 139
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1023
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/TopToolBar/separators.c b/plugins/TopToolBar/separators.c
new file mode 100644
index 0000000000..3be5e056a3
--- /dev/null
+++ b/plugins/TopToolBar/separators.c
@@ -0,0 +1,111 @@
+
+#include "common.h"
+#pragma hdrstop
+
+extern HINSTANCE hInst;
+#define MAXSEPS 32
+int Separators[MAXSEPS];
+
+static int SeparatorCnt=0;
+
+int InsertSeparator(int id)
+{
+ TTBButton ttb;
+ char buf[255];
+
+ HBITMAP Separator=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_SEP));
+ //itoa(SeparatorCnt++,buf,10);
+
+ wsprintf(buf,"%s %d",Translate("Separator"),id);
+ memset(&ttb,0,sizeof(ttb));
+ ttb.cbSize=sizeof(ttb);
+ ttb.hbBitmapDown=Separator;
+ ttb.hbBitmapUp=Separator;
+ ttb.dwFlags=TTBBF_VISIBLE|TTBBF_ISSEPARATOR;
+ ttb.pszServiceDown="";
+ ttb.pszServiceUp="";
+ ttb.lParamDown=id;
+ ttb.name=buf;
+ SeparatorCnt++;
+ return(TTBAddButton(&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()
+{
+ char buf[255];
+ char buf1[10];
+ int id,i;
+
+ //must be locked
+ memset(buf,0,sizeof(buf));
+
+ memset(Separators,0,sizeof(Separators));
+ for (i=0;i<MAXSEPS;i++)
+ {
+ memset(buf1,0,sizeof(buf1));
+ _itoa(i,buf1,10);
+ 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];
+ int i;
+ for (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)
+ {
+ int i;
+ for (i=0;i<MAXSEPS;i++)
+ {
+ if (Separators[i]==0)
+ {
+ Separators[i]=InsertSeparator(i);
+ SaveAllSeparators();
+ return(0);
+ };
+ };
+ };
+
+ return(-1);
+};
diff --git a/plugins/TopToolBar/ttb-readme.txt b/plugins/TopToolBar/ttb-readme.txt
new file mode 100644
index 0000000000..9c127d5c71
--- /dev/null
+++ b/plugins/TopToolBar/ttb-readme.txt
@@ -0,0 +1,160 @@
+About
+-----
+
+TopToolBar
+Version 0.7.3.1
+by
+Bethoven (bethoven@mailgate.ru)
+
+Note: This plugin required MultiWindow or clist_mw plugin.
+
+Description
+-----------
+TopToolBar adds buttons in top frame for fast access
+to miranda/plugins functions.
+
+Features
+--------
+
+-Predefined buttons(Hide/Show OfflineUsers,Hide/Show Groups,On/Off Sounds)
+-Services for plugins to add/remove/modify new buttons.
+
+
+WhatsNew
+--------
+11-04-2008 v0.7.3.1
+ - ???
+17-09-2005 v0.7.3.0
+ -Fixed "new separator" bug.
+ -Less flicks on resize.
+ -Removed default bitmaps.
+
+11-09-2005 v0.7.2.0
+ -Removed default bitmaps.
+
+11-09-2005 v0.7.1.0
+ -Fixed drawing of buttons when Themes enabled.
+ -New TTBButtonV2 struct for adding buttons (icon member)
+
+26-06-2005 v0.7.0.0
+ -Supporting for miranda buton class
+ -Supporting for icolib(use with miranda buton class)
+ -Moved background options to Customize
+
+26-05-2005 v0.6.0.12
+ -Fixed show online users button.
+
+16-12-2004 v0.6.0.11
+ -User defined width and height of buttons
+ -Support loading of icons.
+
+23-09-2003 v0.6.0.9
+ -Set all bitmaps by selecting directory.
+
+09-09-2003 v0.6.0.7
+ -Fixed some bugs that may cause crash.
+
+05-05-2003 v0.6
+ -Added 2 new internal buttons Minimize and Find/Add contacts.
+ -Autowraping mode.
+ -Added separators.
+ -Added Launch buttons.
+
+31-03-2003 v0.5.0.1
+ -Added background configuration
+ -Added Button enable/ordering.
+ -You may change button bitmaps.
+ -Added two new internal buttons (MainMenu and Options).
+
+22-03-2003 v0.4.0.1
+ -Fixed runtime button removing.
+ -Fixed ownerdraw borders for buttons.
+
+11-01-2003 v0.4
+ -(dev) Changed service names to sandart look MS_ (thanks hrk).
+ -(dev) Added border drawing.
+ -Added tooltips for buttons.
+
+
+13-12-2002 v0.3
+ -Added services for add/remove additional buttons from plugins.
+ (see m_toptoolbar.h for description)
+ -Added button to quick enable/disable sounds.
+ -All buttons are synchronized. So if you check hide groups
+ from menu, button track this.
+
+
+Bitmap Names
+----------
+TopToolBar search for bitmaps in this pattern.
+Selecteddir/ButtonName_DN.bmp
+Selecteddir/ButtonName_UP.bmp
+Where ButtonName is non localised name of button.
+This chars in name '/','\','*','?','<','>',':','|','"' replaced with '_'
+
+
+Names for standart buttons:
+
+"Find_Add Contacts_DN.bmp"
+"Find_Add Contacts_UP.bmp"
+"Groups On_Off_DN.bmp"
+"Groups On_Off_UP.bmp"
+"Minimize Button_DN.bmp"
+"Minimize Button_UP.bmp"
+"Show Main Menu_DN.bmp"
+"Show Main Menu_UP.bmp"
+"Show only Online Users_DN.bmp"
+"Show only Online Users_UP.bmp"
+"Show Options Page_DN.bmp"
+"Show Options Page_UP.bmp"
+"Sounds Enable_Disable_DN.bmp"
+"Sounds Enable_Disable_UP.bmp"
+
+
+Installation
+------------
+
+Copy the TopToolBar.dll into Miranda's plugin subdirectory.
+
+
+Translation
+-----------
+[Hide Offline Users]
+[Show All Users]
+[Show Groups]
+[Hide Groups]
+[Disable Sounds]
+[Enable Sounds]
+
+
+
+
+Development
+-----------
+My radix 27d,0x1B (BET)
+My base 0x1b000000
+
+Quicksearch base 0x1b000000
+MultiWindow base 0x1b100000
+TopToolBar base 0x1b200000
+SystemStatus base 0x1b300000
+
+
+License
+-------
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
diff --git a/plugins/TopToolBar/ttbopt.c b/plugins/TopToolBar/ttbopt.c
new file mode 100644
index 0000000000..f202e7a6c0
--- /dev/null
+++ b/plugins/TopToolBar/ttbopt.c
@@ -0,0 +1,970 @@
+#include "common.h"
+#include <shlobj.h>
+#pragma hdrstop
+
+static BOOL CALLBACK DlgProcTTBBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+extern int ttbOptionsChanged();
+extern HINSTANCE hInst;
+
+extern TopButtonInt Buttons[MAX_BUTTONS];
+extern int nButtonsCount;
+
+extern SortData arrangedbuts[MAX_BUTTONS];
+
+extern void lockbut();
+extern void ulockbut();
+extern int applyuserbitmaps();
+
+struct OrderData {
+ int dragging;
+ HTREEITEM hDragItem;
+};
+
+char *SetEndSlash(char *str)
+{
+ char *outs;
+ if (str==NULL){return(NULL);};
+ if (strlen(str)==0){return(NULL);};
+ outs=str;
+
+ if (str[strlen(str)-1]!='\\')
+ {
+ outs=(char*)malloc(strlen(str)+3);
+ memset(outs,0,strlen(str)+3);
+ strcat(outs,str);
+ outs[strlen(str)]='\\';
+ //free(str);
+ };
+ return(outs);
+};
+boolean FileExists(char *fname)
+{
+ HANDLE h;
+ WIN32_FIND_DATA wfd;
+
+
+
+ /*
+ h=CreateFile(fname,GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ */
+ memset(&wfd,0,sizeof(wfd));
+ h=FindFirstFile(fname,&wfd);
+
+ if (h==INVALID_HANDLE_VALUE) {
+ return(FALSE);
+ }
+ else
+ {
+ FindClose(h);
+ return(TRUE);
+ };
+
+
+};
+
+
+char *ReplaceBadChar(char *str,char bad,char toreplace)
+{
+ int i;
+ for (i=0;i<strlen(str);i++)
+ {
+ if (str[i]==bad){str[i]=toreplace;};
+ };
+ return(str);
+};
+char *ReplaceAll(char *str)
+{
+ ReplaceBadChar(str,'\\','_');
+ ReplaceBadChar(str,'/','_');
+ ReplaceBadChar(str,'"','_');
+ ReplaceBadChar(str,'?','_');
+ ReplaceBadChar(str,'|','_');
+ ReplaceBadChar(str,'>','_');
+ ReplaceBadChar(str,'<','_');
+ ReplaceBadChar(str,':','_');
+ ReplaceBadChar(str,'*','_');
+
+ return(str);
+};
+
+void AssignBitmapsFromDir(char *dir)
+{
+ char curnameUP[512],curnameDN[512];
+ char ChangedName[512];
+
+ int i;
+
+ if (dir==NULL){return;};
+ if (strlen(dir)==0){return;};
+ dir=SetEndSlash(dir);
+lockbut();
+ for(i=0;i<nButtonsCount;i++) {
+ memset(curnameUP,0,512);
+ memset(curnameDN,0,512);
+
+ memset(ChangedName,0,512);
+ strcpy(ChangedName,Buttons[i].name);
+ ReplaceAll(ChangedName);
+
+ wsprintf(curnameUP,"%s%s_UP.bmp",dir,ChangedName);
+ wsprintf(curnameDN,"%s%s_DN.bmp",dir,ChangedName);
+
+ if (FileExists(curnameUP)){
+ if (Buttons[i].UserDefinedbmUp!=NULL){free(Buttons[i].UserDefinedbmUp);};
+ Buttons[i].UserDefinedbmUp=_strdup(curnameUP);
+ };
+
+ if (FileExists(curnameDN)){
+ if (Buttons[i].UserDefinedbmDown!=NULL){free(Buttons[i].UserDefinedbmDown);};
+ Buttons[i].UserDefinedbmDown=_strdup(curnameDN);
+ };
+
+
+ wsprintf(curnameUP,"%s%s_UP.ico",dir,ChangedName);
+ wsprintf(curnameDN,"%s%s_DN.ico",dir,ChangedName);
+
+ if (FileExists(curnameUP)){
+ if (Buttons[i].UserDefinedbmUp!=NULL){free(Buttons[i].UserDefinedbmUp);};
+ Buttons[i].UserDefinedbmUp=_strdup(curnameUP);
+ };
+
+ if (FileExists(curnameDN)){
+ if (Buttons[i].UserDefinedbmDown!=NULL){free(Buttons[i].UserDefinedbmDown);};
+ Buttons[i].UserDefinedbmDown=_strdup(curnameDN);
+ };
+ //applyuserbitmaps(i);
+
+ };
+
+ulockbut();
+SetAllBitmaps();
+SaveAllButtonsOptions();
+};
+
+void ApplyNewDir(HWND hwnd)
+{
+ char buf[512];
+ char *buf2;
+ GetDlgItemText(hwnd,IDC_IMGDIR,buf,512);
+ buf2=DBGetString(0,TTB_OPTDIR,"ImgDir");
+ if ((buf2==NULL)||strcmp(buf,buf2))
+ {
+ DBWriteContactSettingString(0,TTB_OPTDIR,"ImgDir",buf);
+ AssignBitmapsFromDir(buf);
+
+ };
+
+
+};
+
+
+//call this when options opened and buttons added/removed
+int OptionsPageRebuild()
+{
+
+ if (OptionsOpened)
+ {
+ //MessageBoxA(0,"TreeRebuild","log",0);
+ BuildTree(OptionshWnd);
+ };
+ return 0;
+};
+int SaveTree(HWND hwndDlg)
+{
+ TVITEM tvi;
+ int count;
+ char idstr[100];
+ char *name;
+ int pos;
+
+ tvi.hItem=TreeView_GetRoot(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE));
+ tvi.cchTextMax=99;
+ tvi.mask=TVIF_TEXT|TVIF_PARAM|TVIF_HANDLE;
+ tvi.pszText=(LPSTR)&idstr;
+ //CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&count,(LPARAM)&protos);
+ //count--;
+ count=0;
+ lockbut();
+
+ while(tvi.hItem!=NULL) {
+ //itoa(count,buf,10);
+ TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvi);
+ name=((ButtonOptData *)tvi.lParam)->name;
+ pos=((ButtonOptData *)tvi.lParam)->pos;
+ if (pos>=0&&pos<nButtonsCount)
+ {
+ Buttons[pos].dwFlags&=~(TTBBF_VISIBLE);
+ Buttons[pos].dwFlags|=(((ButtonOptData *)tvi.lParam)->show==TRUE )?TTBBF_VISIBLE:0;
+ Buttons[pos].arrangedpos=count;
+ // int DBSaveButtonSettings(int butpos)
+ };
+
+
+ tvi.hItem=TreeView_GetNextSibling(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),tvi.hItem);
+
+ count++;
+ }
+ ulockbut();
+ ttbOptionsChanged();
+ return (TRUE);
+};
+
+int BuildTree(HWND hwndDlg)
+{
+ struct OrderData *dat;
+ TVINSERTSTRUCT tvis;
+ ButtonOptData *PD;
+ int i;
+
+ PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,IMAGE_BITMAP,0);
+ PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,IMAGE_BITMAP,0);
+
+ // LockWindowUpdate(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE));
+ dat=(struct OrderData*)GetWindowLong(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),GWLP_USERDATA);
+ tvis.hParent=NULL;
+ tvis.hInsertAfter=TVI_LAST;
+ tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ TreeView_DeleteAllItems(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE));
+ //CheckBUTORDER();
+
+
+ if (nButtonsCount==0){return(FALSE);};
+
+ for(i=0;i<nButtonsCount;i++) {
+ PD=(ButtonOptData*)malloc(sizeof(ButtonOptData));
+
+ PD->name=Buttons[arrangedbuts[i].oldpos].name;
+ PD->show=Buttons[arrangedbuts[i].oldpos].dwFlags&TTBBF_VISIBLE?TRUE:FALSE;
+ PD->pos=arrangedbuts[i].oldpos;
+ tvis.item.lParam=(LPARAM)PD;
+ tvis.item.pszText=Translate(PD->name);
+ tvis.item.iImage=tvis.item.iSelectedImage=PD->show;
+ TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvis);
+
+ tvis.item.iImage=tvis.item.iSelectedImage=PD->show;
+ };
+ // LockWindowUpdate(NULL);
+ return (TRUE);
+};
+
+void SetImagesForCurrent (HWND hwndDlg,int curselect)
+{
+
+ {
+
+ int t=IMAGE_BITMAP;
+ char *curname;
+
+ PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,t,0);
+ PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,t,0);
+
+ curname=Buttons[curselect].UserDefinedbmUp;
+ if (curname!=NULL)
+ {
+ int st;
+ if (strstr(curname,".ico")) {t=IMAGE_ICON;};
+ st=WS_CHILDWINDOW|SS_NOTIFY|WS_VISIBLE;(t==IMAGE_ICON)?(st|=SS_ICON):(st|=SS_BITMAP);
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_BMPUP),GWL_STYLE,st);
+ }else
+ {
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_BMPUP),GWL_STYLE,WS_CHILDWINDOW|WS_VISIBLE|SS_NOTIFY|(Buttons[curselect].hbBitmapDown==NULL?SS_ICON:SS_BITMAP));
+ t=IMAGE_ICON;
+ }
+
+ PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,t,(LPARAM)(Buttons[curselect].hbBitmapUp==NULL?Buttons[curselect].hIconUp:Buttons[curselect].hbBitmapUp));
+
+ curname=Buttons[curselect].UserDefinedbmDown;
+ if (curname!=NULL)
+ {
+ int st;
+ if (strstr(curname,".ico")) {t=IMAGE_ICON;};
+ st=WS_CHILDWINDOW|SS_NOTIFY|WS_VISIBLE;(t==IMAGE_ICON)?(st|=SS_ICON):(st|=SS_BITMAP);
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_BMPDN),GWL_STYLE,st);
+ }else
+ {
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_BMPDN),GWL_STYLE,WS_CHILDWINDOW|WS_VISIBLE|SS_NOTIFY|(Buttons[curselect].hbBitmapDown==NULL?SS_ICON:SS_BITMAP));
+ t=IMAGE_ICON;
+ }
+
+ PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,t,(LPARAM)(Buttons[curselect].hbBitmapDown==NULL?Buttons[curselect].hIconDn:Buttons[curselect].hbBitmapDown ));
+ }
+}
+
+static BOOL CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{ struct OrderData *dat;
+
+ dat=(struct OrderData*)GetWindowLong(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),GWLP_USERDATA);
+
+ switch (msg)
+ {
+ case WM_INITDIALOG: {
+
+
+ TranslateDialogDefault(hwndDlg);
+ dat=(struct OrderData*)malloc(sizeof(struct OrderData));
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),GWLP_USERDATA,(LONG)dat);
+ dat->dragging=0;
+
+ //SetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),GWL_STYLE,GetWindowLong(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),GWL_STYLE)|TVS_NOHSCROLL);
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),GWL_STYLE,GetWindowLong(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),GWL_STYLE)|TVS_NOHSCROLL);
+
+ { HIMAGELIST himlCheckBoxes;
+ himlCheckBoxes=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR4|ILC_MASK,2,2);
+ ImageList_AddIcon(himlCheckBoxes,LoadIcon(hInst,MAKEINTRESOURCE(IDI_NOTICK)));
+ ImageList_AddIcon(himlCheckBoxes,LoadIcon(hInst,MAKEINTRESOURCE(IDI_TICK)));
+ //TreeView_SetImageList(GetDlgItem(hwndDlg,IDC_PROTOCOLVISIBILITY),himlCheckBoxes,TVSIL_NORMAL);
+ //
+ TreeView_SetImageList(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),himlCheckBoxes,TVSIL_NORMAL);
+
+ }
+ PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,IMAGE_BITMAP,0);
+ PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,IMAGE_BITMAP,0);
+ SetDlgItemInt(hwndDlg,IDC_BUTTHEIGHT,DBGetContactSettingByte(0,TTB_OPTDIR,"BUTTHEIGHT",16),FALSE);
+ SetDlgItemInt(hwndDlg,IDC_BUTTWIDTH,DBGetContactSettingByte(0,TTB_OPTDIR,"BUTTWIDTH",20),FALSE);
+ CheckDlgButton(hwndDlg,IDC_USEMIRANDABUTTON,DBGetContactSettingByte(0,TTB_OPTDIR,"UseMirandaButtonClass",UseMirandaButtonClassDefaultValue));
+ CheckDlgButton(hwndDlg,IDC_USEFLAT,DBGetContactSettingByte(0,TTB_OPTDIR,"UseFlatButton",1));
+
+ if (!ServiceExists(MS_SKIN2_ADDICON))
+ {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_USEICOLIB),FALSE);
+ }
+ CheckDlgButton(hwndDlg,IDC_USEICOLIB,ServiceExists(MS_SKIN2_ADDICON)&&DBGetContactSettingByte(0,TTB_OPTDIR,"UseIcoLib",UseIcoLibDefaultValue));
+
+
+
+ BuildTree(hwndDlg);
+ OptionsOpened=TRUE;
+ EnableWindow(GetDlgItem(hwndDlg,IDC_ENAME),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_EPATH),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_DELLBUTTON),FALSE);
+
+ SetDlgItemText(hwndDlg,IDC_IMGDIR,DBGetString(0,TTB_OPTDIR,"ImgDir"));
+ SendMessage(hwndDlg,WM_COMMAND,0,0);
+ OptionshWnd=hwndDlg;
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ //if (IDC_BMPUP)
+ ShowWindow(GetDlgItem(hwndDlg,IDC_BMPUP),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg,IDC_BMPDN),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg,IDC_DEFAULT),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW);
+
+ ShowWindow(GetDlgItem(hwndDlg,IDC_STATIC1),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg,IDC_STATIC2),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg,IDC_STATIC3),IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB)?SW_HIDE:SW_SHOW);
+
+ EnableWindow(GetDlgItem(hwndDlg,IDC_USEFLAT),IsDlgButtonChecked(hwndDlg,IDC_USEMIRANDABUTTON));
+
+ if (HIWORD(wParam)==EN_CHANGE )
+ {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ };
+ if ((HIWORD(wParam)==BN_CLICKED|| HIWORD(wParam)==BN_DBLCLK))
+ {
+ int ctrlid=LOWORD(wParam);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+
+ if (ctrlid==IDC_OPENIMGDIR)
+ {
+ char buf[512];
+ PCIDLIST_ABSOLUTE res;
+
+ BROWSEINFO bi;
+ memset(&bi,0,sizeof(bi));
+ bi.hwndOwner=hwndDlg;
+ bi.pszDisplayName=buf;
+ bi.lpszTitle=Translate("Select Directory");
+ bi.ulFlags=BIF_RETURNONLYFSDIRS;
+ res=SHBrowseForFolder(&bi);
+ if(res!=NULL)
+ {
+ if (SHGetPathFromIDList(res,buf)==TRUE)
+ {
+
+ SetDlgItemText(hwndDlg,IDC_IMGDIR,(LPCSTR)&buf);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ };
+
+ };
+
+ break;
+ };
+ if (ctrlid==IDC_LBUTTONSET)
+ {
+ int curselect;
+ 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);
+
+ curselect=((ButtonOptData *)tvi.lParam)->pos;
+ if (Buttons[curselect].dwFlags&TTBBF_ISLBUTTON)
+ {
+ LBUTOPT lbo;
+ char buf[256];
+ memset(&lbo,0,sizeof(lbo));
+
+
+ GetDlgItemText(hwndDlg,IDC_ENAME,buf,255);
+ lbo.name=_strdup(buf);
+
+ GetDlgItemText(hwndDlg,IDC_EPATH,buf,255);
+ lbo.lpath=_strdup(buf);
+
+ CallService(TTB_MODIFYLBUTTON,Buttons[curselect].lParamDown,(LPARAM)&lbo);
+ free(lbo.name);
+ free(lbo.lpath);
+ };
+
+ break;
+ };
+ if (ctrlid==IDC_ADDLBUTTON)
+ {
+ if (CallService(TTB_ADDLBUTTON,0,0)==0)
+ {
+ // BuildTree(hwndDlg);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+
+ };
+ break;
+ };
+
+ if (ctrlid==IDC_DELLBUTTON)
+ {
+ int curselect;
+ 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);
+
+ curselect=((ButtonOptData *)tvi.lParam)->pos;
+ if (Buttons[curselect].dwFlags&TTBBF_ISLBUTTON)
+ {
+ CallService(TTB_REMOVELBUTTON,Buttons[curselect].lParamDown,0);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_ENAME),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_EPATH),FALSE);
+ BuildTree(hwndDlg);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+
+ };
+
+
+ };
+ if (ctrlid==IDC_ADDSEP)
+ {
+ if (CallService(TTB_ADDSEPARATOR,0,0)==0)
+ {
+ // BuildTree(hwndDlg);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ };
+ break;
+ };
+ if (ctrlid==IDC_REMOVESEP)
+ {
+ int curselect;
+ TVITEM tvi;
+ memset(&tvi,0,sizeof(tvi));
+ tvi.hItem=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE));
+ if (tvi.hItem==NULL){break;};
+
+ //MessageBoxA(0,"GetSelItem","log",0);
+ tvi.mask=TVIF_PARAM;
+ TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvi);
+
+ if (tvi.lParam==0){break;};
+ //MessageBoxA(0,"Getting curselect","log",0);
+ //!!! in win98 cause crash ?
+ if (IsBadCodePtr(tvi.lParam))
+ {
+ MessageBoxA(0,"Bad Code Ptr: tvi.lParam","log",0);
+ break;
+ };
+ curselect=((ButtonOptData *)tvi.lParam)->pos;
+
+ if ((curselect>=0)&&(curselect<nButtonsCount))
+ {
+ if (Buttons[curselect].dwFlags&TTBBF_ISSEPARATOR)
+ {
+ //wsprintf(buf,"curselect: %d/%d, lparamdown: %d",curselect,nButtonsCount,Buttons[curselect].lParamDown);
+ //MessageBoxA(0,buf,"log",0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ //MessageBoxA(0,"CallService(TTB_REMOVESEPARATOR","log",0);
+ CallService(TTB_REMOVESEPARATOR,Buttons[curselect].lParamDown,0);
+
+
+ //MessageBoxA(0,"Remove OK","log",0);
+ };
+ }
+
+ break;
+ };
+ if (ctrlid==IDC_DEFAULT)
+ {
+ int curselect;
+ 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);
+
+ curselect=((ButtonOptData *)tvi.lParam)->pos;
+ lockbut();
+
+ if (Buttons[curselect].UserDefinedbmUp!=NULL){free(Buttons[curselect].UserDefinedbmUp);};
+ if (Buttons[curselect].UserDefinedbmDown!=NULL){free(Buttons[curselect].UserDefinedbmDown);};
+ Buttons[curselect].UserDefinedbmUp=NULL;
+ Buttons[curselect].UserDefinedbmDown=NULL;
+ applyuserbitmaps(curselect);
+ SetImagesForCurrent(hwndDlg,curselect);
+ //PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,IMAGE_BITMAP,Buttons[curselect].hbBitmapUp);
+ //PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,IMAGE_BITMAP,Buttons[curselect].hbBitmapDown);
+
+ ulockbut();
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ };
+ };
+
+ if ((HIWORD(wParam)==STN_CLICKED|| HIWORD(wParam)==STN_DBLCLK))
+ {
+ int ctrlid=LOWORD(wParam);
+ if (ctrlid==IDC_BMPUP||ctrlid==IDC_BMPDN)
+ {
+
+
+ char filename[MAX_PATH];
+ OPENFILENAME ofn={0};
+ char filter[512],*pfilter;
+ int curselect;
+ 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);
+
+ if (tvi.lParam==0){break;};
+ curselect=((ButtonOptData *)tvi.lParam)->pos;
+
+
+ filename[0]=0;
+ memset(&ofn,0,sizeof(ofn));
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hwndDlg;
+ ofn.hInstance = NULL;
+ strcpy(filter,Translate("Bitmap/Icon files"));
+ //sprintf(filter,"Bitmap/Icon files \0 *.bmp;*.ico \0\0" );
+
+ strcat(filter," (*.bmp;*.ico)");
+
+ pfilter=filter+strlen(filter)+1;
+ strcpy(pfilter,"*.bmp;*.ico");
+ pfilter=pfilter+strlen(pfilter)+1;
+
+ strcpy(pfilter,Translate("All Files"));
+ strcat(pfilter,"(*)");
+ pfilter=pfilter+strlen(pfilter)+1;
+ strcpy(pfilter,"*");
+
+
+ pfilter=pfilter+strlen(pfilter)+1;
+ *pfilter='\0';
+
+ ofn.lpstrFilter = filter;
+ ofn.lpstrFile = filename;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+ ofn.nMaxFile = sizeof(filename);
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.lpstrDefExt = "bmp";
+ ofn.lpstrTitle=(ctrlid==IDC_BMPUP)?Translate("Select Up Bitmap"):Translate("Select Down Bitmap");
+ if(GetOpenFileName(&ofn)) {
+ lockbut();
+ if (ctrlid==IDC_BMPUP){
+ if (Buttons[curselect].UserDefinedbmUp!=NULL){free(Buttons[curselect].UserDefinedbmUp);};
+ Buttons[curselect].UserDefinedbmUp=_strdup(ofn.lpstrFile);
+ };
+ if (ctrlid==IDC_BMPDN){
+ if (Buttons[curselect].UserDefinedbmDown!=NULL){free(Buttons[curselect].UserDefinedbmDown);};
+ Buttons[curselect].UserDefinedbmDown=_strdup(ofn.lpstrFile);
+ };
+ applyuserbitmaps(curselect);
+ SetImagesForCurrent(hwndDlg,curselect);
+
+ ulockbut();
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ };
+ };
+ };
+ break;
+ }
+
+
+
+
+
+
+
+
+
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+
+ DBWriteContactSettingByte(0,TTB_OPTDIR,"BUTTHEIGHT",GetDlgItemInt(hwndDlg,IDC_BUTTHEIGHT,FALSE,FALSE));
+ DBWriteContactSettingByte(0,TTB_OPTDIR,"BUTTWIDTH",GetDlgItemInt(hwndDlg,IDC_BUTTWIDTH,FALSE,FALSE));
+ DBWriteContactSettingByte(0,TTB_OPTDIR,"UseMirandaButtonClass",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USEMIRANDABUTTON));
+ DBWriteContactSettingByte(0,TTB_OPTDIR,"UseFlatButton",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USEFLAT));
+
+ DBWriteContactSettingByte(0,TTB_OPTDIR,"UseIcoLib",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_USEICOLIB));
+
+
+ SaveTree(hwndDlg);
+ ApplyNewDir(hwndDlg);
+ RecreateWindows();
+ ArrangeButtons();
+
+ }
+ }
+ break;
+ case IDC_BUTTONORDERTREE:
+ switch (((LPNMHDR)lParam)->code) {
+ case TVN_BEGINDRAG:
+ SetCapture(hwndDlg);
+ dat->dragging=1;
+ dat->hDragItem=((LPNMTREEVIEW)lParam)->itemNew.hItem;
+ TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),dat->hDragItem);
+ //ShowWindow(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREEWARNING),SW_SHOW);
+ break;
+
+ case NM_CLICK:
+ {
+ TVHITTESTINFO hti;
+ hti.pt.x=(short)LOWORD(GetMessagePos());
+ hti.pt.y=(short)HIWORD(GetMessagePos());
+ ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt);
+ if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti))
+ {
+ if(hti.flags&TVHT_ONITEMICON) {
+ TVITEM tvi;
+ tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
+ tvi.hItem=hti.hItem;
+ TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi);
+ tvi.iImage=tvi.iSelectedImage=!tvi.iImage;
+ ((ButtonOptData *)tvi.lParam)->show=tvi.iImage;
+ TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom,&tvi);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+
+ //all changes take effect in runtime
+ //ShowWindow(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREEWARNING),SW_SHOW);
+ }
+
+
+ };
+ }
+ break;
+ case TVN_SELCHANGED:
+
+ {
+
+ if(1/*TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)*/)
+ if (1/*hti.flags&TVHT_ONITEMLABEL*/)
+ {
+ TVITEM tvi;
+ HTREEITEM hti;
+
+ hti=TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE));
+ if (hti==NULL){break;};
+ tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
+ tvi.hItem=hti;
+ TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvi);
+
+
+ lockbut();
+ EnableWindow(GetDlgItem(hwndDlg,IDC_BMPUP),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_BMPDN),FALSE);
+
+ SetImagesForCurrent(hwndDlg,((ButtonOptData *)tvi.lParam)->pos);
+ //PostMessage(GetDlgItem(hwndDlg,IDC_BMPUP), STM_SETIMAGE,IMAGE_BITMAP,Buttons[((ButtonOptData *)tvi.lParam)->pos].hbBitmapUp);
+ //PostMessage(GetDlgItem(hwndDlg,IDC_BMPDN), STM_SETIMAGE,IMAGE_BITMAP,Buttons[((ButtonOptData *)tvi.lParam)->pos].hbBitmapDown);
+
+ EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVESEP),FALSE);
+ if (Buttons[((ButtonOptData *)tvi.lParam)->pos].dwFlags&TTBBF_ISSEPARATOR)
+ {
+
+ EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVESEP),TRUE);
+ }else
+ {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_BMPUP),TRUE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_BMPDN),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);
+ {SetDlgItemText(hwndDlg,IDC_ENAME,"");}
+ {SetDlgItemText(hwndDlg,IDC_EPATH,"");}
+
+
+ if (Buttons[((ButtonOptData *)tvi.lParam)->pos].dwFlags&TTBBF_ISLBUTTON)
+ {
+ LBUTOPT lbo;
+
+ memset(&lbo,0,sizeof(lbo));
+ CallService(TTB_GETLBUTTON,Buttons[((ButtonOptData *)tvi.lParam)->pos].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){SetDlgItemText(hwndDlg,IDC_ENAME,lbo.name);};
+ if (lbo.lpath!=NULL){SetDlgItemText(hwndDlg,IDC_EPATH,lbo.lpath);};
+ };
+
+
+ };
+
+ ulockbut();
+ };
+
+
+
+ };
+
+
+
+ }
+ break;
+ }
+ break;
+ case WM_MOUSEMOVE:
+ if(!dat->dragging) break;
+ { TVHITTESTINFO hti;
+ hti.pt.x=(short)LOWORD(lParam);
+ hti.pt.y=(short)HIWORD(lParam);
+ ClientToScreen(hwndDlg,&hti.pt);
+ ScreenToClient(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&hti.pt);
+ TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&hti);
+ if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) {
+ hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE))/2;
+ TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&hti);
+ TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),hti.hItem,1);
+ }
+ else {
+ if(hti.flags&TVHT_ABOVE) SendDlgItemMessage(hwndDlg,IDC_BUTTONORDERTREE,WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),0);
+ if(hti.flags&TVHT_BELOW) SendDlgItemMessage(hwndDlg,IDC_BUTTONORDERTREE,WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),0);
+ TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),NULL,0);
+ }
+
+ }
+ break;
+ case WM_DESTROY:
+ {
+ OptionsOpened=FALSE;
+ return(0);
+ };
+
+ case WM_LBUTTONUP:
+ if(!dat->dragging) break;
+ TreeView_SetInsertMark(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),NULL,0);
+ dat->dragging=0;
+ ReleaseCapture();
+ { TVHITTESTINFO hti;
+ TVITEM tvi;
+ hti.pt.x=(short)LOWORD(lParam);
+ hti.pt.y=(short)HIWORD(lParam);
+ ClientToScreen(hwndDlg,&hti.pt);
+ ScreenToClient(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&hti.pt);
+ hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE))/2;
+ TreeView_HitTest(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&hti);
+ if(dat->hDragItem==hti.hItem) break;
+ tvi.mask=TVIF_HANDLE|TVIF_PARAM;
+ tvi.hItem=hti.hItem;
+ TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvi);
+ if(hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) {
+ TVINSERTSTRUCT tvis;
+ char name[128];
+ tvis.item.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ tvis.item.stateMask=0xFFFFFFFF;
+ tvis.item.pszText=name;
+ tvis.item.cchTextMax=sizeof(name);
+ tvis.item.hItem=dat->hDragItem;
+ //
+ tvis.item.iImage=tvis.item.iSelectedImage=((ButtonOptData *)tvi.lParam)->show;
+
+ TreeView_GetItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvis.item);
+
+
+ TreeView_DeleteItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),dat->hDragItem);
+ tvis.hParent=NULL;
+ tvis.hInsertAfter=hti.hItem;
+ TreeView_SelectItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),TreeView_InsertItem(GetDlgItem(hwndDlg,IDC_BUTTONORDERTREE),&tvis));
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ SaveTree(hwndDlg);
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+
+
+int TTBOptInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp;
+
+ ZeroMemory(&odp,sizeof(odp));
+ odp.cbSize=sizeof(odp);
+ odp.position=0;
+ odp.hInstance=hInst;
+ odp.pszGroup=Translate("TopToolBar");
+
+ if (ServiceExists(MS_BACKGROUNDCONFIG_REGISTER))
+ {
+
+ }else
+ {
+ odp.pszTemplate=MAKEINTRESOURCE(IDD_OPT_TTBBKG);
+ odp.pszTitle=Translate("TTBBackground");
+ odp.pfnDlgProc=DlgProcTTBBkgOpts;
+ odp.flags=ODPF_BOLDGROUPS;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+ };
+
+ ZeroMemory(&odp,sizeof(odp));
+ odp.cbSize=sizeof(odp);
+ odp.position=-1000000000;
+ odp.hInstance=hInst;//GetModuleHandle(NULL);
+ odp.pszTemplate=MAKEINTRESOURCE(IDD_OPT_BUTORDER);
+ odp.pszGroup=Translate("TopToolBar");
+ odp.pszTitle=Translate("Buttons");
+ odp.pfnDlgProc=ButOrderOpts;
+ odp.flags=ODPF_BOLDGROUPS|ODPF_EXPERTONLY;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+
+ return 0;
+}
+
+static BOOL CALLBACK DlgProcTTBBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ CheckDlgButton(hwndDlg,IDC_BITMAP,DBGetContactSettingByte(NULL,TTB_OPTDIR,"UseBitmap",TTBDEFAULT_USEBITMAP)?BST_CHECKED:BST_UNCHECKED);
+ SendMessage(hwndDlg,WM_USER+10,0,0);
+ SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETDEFAULTCOLOUR,0,TTBDEFAULT_BKCOLOUR);
+ SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,TTB_OPTDIR,"BkColour",TTBDEFAULT_BKCOLOUR));
+ SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETDEFAULTCOLOUR,0,TTBDEFAULT_SELBKCOLOUR);
+ SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_SETCOLOUR,0,DBGetContactSettingDword(NULL,TTB_OPTDIR,"SelBkColour",TTBDEFAULT_SELBKCOLOUR));
+ { DBVARIANT dbv;
+ if(!DBGetContactSetting(NULL,TTB_OPTDIR,"BkBitmap",&dbv)) {
+ SetDlgItemText(hwndDlg,IDC_FILENAME,dbv.pszVal);
+ DBFreeVariant(&dbv);
+
+ }
+ }
+ { WORD bmpUse=DBGetContactSettingWord(NULL,TTB_OPTDIR,"BkBmpUse",TTBDEFAULT_BKBMPUSE);
+ CheckDlgButton(hwndDlg,IDC_STRETCHH,bmpUse&CLB_STRETCHH?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_STRETCHV,bmpUse&CLB_STRETCHV?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_TILEH,bmpUse&CLBF_TILEH?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_TILEV,bmpUse&CLBF_TILEV?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_SCROLL,bmpUse&CLBF_SCROLL?BST_CHECKED:BST_UNCHECKED);
+ CheckDlgButton(hwndDlg,IDC_PROPORTIONAL,bmpUse&CLBF_PROPORTIONAL?BST_CHECKED:BST_UNCHECKED);
+ }
+ { HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD);
+ MySHAutoComplete=(HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandle("shlwapi"),"SHAutoComplete");
+ if(MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1);
+ }
+ return TRUE;
+ case WM_USER+10:
+ EnableWindow(GetDlgItem(hwndDlg,IDC_FILENAME),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_BROWSE),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_STRETCHV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_TILEH),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_TILEV),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_SCROLL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ EnableWindow(GetDlgItem(hwndDlg,IDC_PROPORTIONAL),IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ break;
+ case WM_COMMAND:
+ if(LOWORD(wParam)==IDC_BROWSE) {
+ char str[MAX_PATH];
+ OPENFILENAME ofn={0};
+ char filter[512];
+
+ GetDlgItemText(hwndDlg,IDC_FILENAME,str,sizeof(str));
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hwndDlg;
+ ofn.hInstance = NULL;
+ CallService(MS_UTILS_GETBITMAPFILTERSTRINGS,sizeof(filter),(LPARAM)filter);
+ ofn.lpstrFilter = filter;
+ ofn.lpstrFile = str;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+ ofn.nMaxFile = sizeof(str);
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.lpstrDefExt = "bmp";
+ if(!GetOpenFileName(&ofn)) break;
+ SetDlgItemText(hwndDlg,IDC_FILENAME,str);
+ }
+ else if(LOWORD(wParam)==IDC_FILENAME && HIWORD(wParam)!=EN_CHANGE) break;
+ if(LOWORD(wParam)==IDC_BITMAP) SendMessage(hwndDlg,WM_USER+10,0,0);
+ if(LOWORD(wParam)==IDC_FILENAME && (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())) return 0;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ DBWriteContactSettingByte(NULL,TTB_OPTDIR,"UseBitmap",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_BITMAP));
+ { COLORREF col;
+ col=SendDlgItemMessage(hwndDlg,IDC_BKGCOLOUR,CPM_GETCOLOUR,0,0);
+ if(col==TTBDEFAULT_BKCOLOUR) DBDeleteContactSetting(NULL,TTB_OPTDIR,"BkColour");
+ else DBWriteContactSettingDword(NULL,TTB_OPTDIR,"BkColour",col);
+ col=SendDlgItemMessage(hwndDlg,IDC_SELCOLOUR,CPM_GETCOLOUR,0,0);
+ if(col==TTBDEFAULT_SELBKCOLOUR) DBDeleteContactSetting(NULL,TTB_OPTDIR,"SelBkColour");
+ else DBWriteContactSettingDword(NULL,TTB_OPTDIR,"SelBkColour",col);
+ }
+ { char str[MAX_PATH];
+ GetDlgItemText(hwndDlg,IDC_FILENAME,str,sizeof(str));
+ DBWriteContactSettingString(NULL,TTB_OPTDIR,"BkBitmap",str);
+ }
+ { WORD flags=0;
+ if(IsDlgButtonChecked(hwndDlg,IDC_STRETCHH)) flags|=CLB_STRETCHH;
+ if(IsDlgButtonChecked(hwndDlg,IDC_STRETCHV)) flags|=CLB_STRETCHV;
+ if(IsDlgButtonChecked(hwndDlg,IDC_TILEH)) flags|=CLBF_TILEH;
+ if(IsDlgButtonChecked(hwndDlg,IDC_TILEV)) flags|=CLBF_TILEV;
+ if(IsDlgButtonChecked(hwndDlg,IDC_SCROLL)) flags|=CLBF_SCROLL;
+ if(IsDlgButtonChecked(hwndDlg,IDC_PROPORTIONAL)) flags|=CLBF_PROPORTIONAL;
+ DBWriteContactSettingWord(NULL,TTB_OPTDIR,"BkBmpUse",flags);
+ }
+
+ ttbOptionsChanged();
+ return TRUE;
+ }
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}