summaryrefslogtreecommitdiff
path: root/plugins/TopToolBar/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/TopToolBar/src')
-rw-r--r--plugins/TopToolBar/src/main.cpp44
-rw-r--r--plugins/TopToolBar/src/stdafx.h10
-rw-r--r--plugins/TopToolBar/src/toolbar.cpp4
-rw-r--r--plugins/TopToolBar/src/toolbarwnd.cpp619
-rw-r--r--plugins/TopToolBar/src/topbutton.cpp4
-rw-r--r--plugins/TopToolBar/src/ttbopt.cpp6
6 files changed, 343 insertions, 344 deletions
diff --git a/plugins/TopToolBar/src/main.cpp b/plugins/TopToolBar/src/main.cpp
index 3b0339e9fc..ee8cdebcdc 100644
--- a/plugins/TopToolBar/src/main.cpp
+++ b/plugins/TopToolBar/src/main.cpp
@@ -1,9 +1,25 @@
#include "stdafx.h"
-CLIST_INTERFACE *pcli;
-HINSTANCE hInst;
int hLangpack;
+CMPlugin g_plugin;
+CLIST_INTERFACE *pcli;
+
+IconItem iconList[] =
+{
+ { LPGEN("Execute"), "run", IDI_RUN },
+ { LPGEN("Hide offline contacts"), "hide_offline", IDI_HIDEOFFLINE },
+ { LPGEN("Show offline contacts"), "show_offline", IDI_SHOWOFFLINE },
+ { LPGEN("Disable groups"), "groups_off", IDI_GROUPSOFF },
+ { LPGEN("Enable groups"), "groups_on", IDI_GROUPSON },
+ { LPGEN("Disable sounds"), "sounds_off", IDI_SOUNDSOFF },
+ { LPGEN("Enable sounds"), "sounds_on", IDI_SOUNDSON },
+ { LPGEN("Disable metacontacts"), "meta_off", IDI_METAON },
+ { LPGEN("Enable metacontacts"), "meta_on", IDI_METAOFF },
+ { LPGEN("Separator"), "separator", IDI_SEPARATOR }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfo =
{
@@ -24,20 +40,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
return &pluginInfo;
}
-IconItem iconList[] =
-{
- { LPGEN("Execute"), "run", IDI_RUN },
- { LPGEN("Hide offline contacts"), "hide_offline", IDI_HIDEOFFLINE },
- { LPGEN("Show offline contacts"), "show_offline", IDI_SHOWOFFLINE },
- { LPGEN("Disable groups"), "groups_off", IDI_GROUPSOFF },
- { LPGEN("Enable groups"), "groups_on", IDI_GROUPSON },
- { LPGEN("Disable sounds"), "sounds_off", IDI_SOUNDSOFF },
- { LPGEN("Enable sounds"), "sounds_on", IDI_SOUNDSON },
- { LPGEN("Disable metacontacts"), "meta_off", IDI_METAON },
- { LPGEN("Enable metacontacts"), "meta_on", IDI_METAOFF },
- { LPGEN("Separator"), "separator", IDI_SEPARATOR }
-};
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" int __declspec(dllexport) Load(void)
@@ -45,7 +47,7 @@ extern "C" int __declspec(dllexport) Load(void)
mir_getLP(&pluginInfo);
pcli = Clist_GetInterface();
- Icon_Register(hInst, TTB_OPTDIR, iconList, _countof(iconList), TTB_OPTDIR);
+ Icon_Register(g_plugin.getInst(), TTB_OPTDIR, iconList, _countof(iconList), TTB_OPTDIR);
LoadToolbarModule();
return 0;
@@ -58,11 +60,3 @@ extern "C" int __declspec(dllexport) Unload(void)
UnloadToolbarModule();
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
diff --git a/plugins/TopToolBar/src/stdafx.h b/plugins/TopToolBar/src/stdafx.h
index 06f934ee19..b8d387cfde 100644
--- a/plugins/TopToolBar/src/stdafx.h
+++ b/plugins/TopToolBar/src/stdafx.h
@@ -1,12 +1,10 @@
#ifndef TTB_COMMON_H
#define TTB_COMMON_H
-
#include <windows.h>
#include <commctrl.h>
#include <stddef.h>
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
#include <newpluginapi.h>
#include <m_database.h>
@@ -39,6 +37,13 @@
#define TTBBF_INTERNAL 0x1000000
#define TTBBF_OPTIONAL 0x2000000
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(TTB_OPTDIR)
+ {}
+};
+
///////////////////////////////////////////////////////////////////////////////
// TopButtonInt class
@@ -103,7 +108,6 @@ int ArrangeButtons();
extern TTBCtrl* g_ctrl;
extern LIST<TopButtonInt> Buttons;
-extern HINSTANCE hInst;
extern HBITMAP hBmpBackground;
extern mir_cs csButtonsHook;
extern pfnCustomProc g_CustomProc;
diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp
index 7201f1be7c..a3fbea4ad6 100644
--- a/plugins/TopToolBar/src/toolbar.cpp
+++ b/plugins/TopToolBar/src/toolbar.cpp
@@ -41,8 +41,8 @@ TopButtonInt *idtopos(int id, int *pPos)
void InsertSBut(int i)
{
TTBButton ttb = {};
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.hIconDn = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.hIconUp = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSBUTTON | TTBBF_INTERNAL;
ttb.wParamDown = i;
TTBAddButton((WPARAM)&ttb, 0);
diff --git a/plugins/TopToolBar/src/toolbarwnd.cpp b/plugins/TopToolBar/src/toolbarwnd.cpp
index 332585f4f1..cef033447d 100644
--- a/plugins/TopToolBar/src/toolbarwnd.cpp
+++ b/plugins/TopToolBar/src/toolbarwnd.cpp
@@ -1,309 +1,310 @@
-
-#include "stdafx.h"
-
-COLORREF bkColour;
-HBITMAP hBmpBackground;
-int backgroundBmpUse;
-
-static wchar_t pluginname[] = L"TopToolBar";
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Toolbar window procedure
-
-static void PaintToolbar(HWND hwnd)
-{
- InvalidateRect(hwnd, nullptr, FALSE);
-
- PAINTSTRUCT paintst;
- HDC hdc = BeginPaint(hwnd, &paintst);
- RECT *rcPaint = &paintst.rcPaint;
-
- RECT clRect;
- GetClientRect(hwnd, &clRect);
-
- int yScroll = 0;
-
- HDC hdcMem = CreateCompatibleDC(hdc);
- HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), nullptr);
- HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcMem, hBmpOsb);
- SetBkMode(hdcMem, TRANSPARENT);
-
- HBRUSH hBrush = CreateSolidBrush(bkColour);
- HBRUSH hoBrush = (HBRUSH)SelectObject(hdcMem, hBrush);
- FillRect(hdcMem, rcPaint, hBrush);
- SelectObject(hdcMem, hoBrush);
- DeleteObject(hBrush);
- if (hBmpBackground) {
- BITMAP bmp;
- GetObject(hBmpBackground, sizeof(bmp), &bmp);
-
- HDC hdcBmp = CreateCompatibleDC(hdcMem);
- SelectObject(hdcBmp, hBmpBackground);
- int y = backgroundBmpUse & CLBF_SCROLL ? -yScroll : 0;
- int maxx = backgroundBmpUse & CLBF_TILEH ? clRect.right : 1;
- int maxy = backgroundBmpUse & CLBF_TILEV ? rcPaint->bottom : y+1;
-
- int destw, desth;
- 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 = g_ctrl->nButtonHeight+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 = g_ctrl->nButtonHeight+2;
- break;
- }
-
- for (; y < maxy; y += desth) {
- if (y < rcPaint->top - desth)
- continue;
-
- for (int 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);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- static bool supressRepos = false;
-
- switch(msg) {
- case WM_CREATE:
- g_ctrl->hWnd = hwnd;
- PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0);
- return FALSE;
-
- case WM_DESTROY:
- g_ctrl->hWnd = nullptr;
- break;
-
- case WM_MOVE:
- return 0;
-
- case WM_WINDOWPOSCHANGING:
- case WM_SIZE:
- if (g_ctrl->nLastHeight != HIWORD(lParam)) {
- db_set_dw(0, TTB_OPTDIR, "LastHeight", g_ctrl->nLastHeight = HIWORD(lParam));
- ArrangeButtons();
- }
- if (supressRepos) {
- supressRepos = false;
- break;
- }
- __fallthrough;
-
- case TTB_REPOSBUTTONS:
- if (g_ctrl->hWnd == hwnd) {
- int iHeight = ArrangeButtons();
- if ( g_ctrl->bAutoSize) {
- RECT rcClient;
- GetClientRect(g_ctrl->hWnd, &rcClient);
- rcClient.bottom -= rcClient.top;
- if (rcClient.bottom != iHeight && iHeight && rcClient.bottom) {
- supressRepos = true;
- PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0);
- }
- }
- return 0;
- }
- break;
-
- case WM_NCPAINT:
- case WM_PAINT:
- PaintToolbar(hwnd);
- return 0;
-
- case WM_LBUTTONDOWN:
- if (db_get_b(NULL, "CLUI", "ClientAreaDrag", 0)) {
- POINT pt;
- GetCursorPos(&pt);
- return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(pt.x, pt.y));
- }
- return 0;
-
- case WM_COMMAND:
- switch (HIWORD(wParam)) {
- case BN_CLICKED:
- case BN_DOUBLECLICKED:
- {
- int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA);
- if (id != 0) {
- mir_cslock lck(csButtonsHook);
- TopButtonInt* b = idtopos(id);
- if (b == nullptr || b->isSep())
- return 0;
-
- if (b->dwFlags & TTBBF_ASPUSHBUTTON)
- b->bPushed = !b->bPushed;
-
- if (b->bPushed) { //Dn -> Up
- if (!(b->dwFlags & TTBBF_ISLBUTTON)) // must be always true
- if (b->pszService != nullptr)
- CallService(b->pszService, b->wParamUp, b->lParamUp);
- }
- else { //Up -> Dn
- if (b->pszService != nullptr)
- CallService(b->pszService, b->wParamDown, b->lParamDown);
- }
-
- b->SetBitmap();
- }
- }
- break;
- }
- break;
-
- case TTB_UPDATEFRAMEVISIBILITY:
- {
- bool bResize = false;
-
- if (g_ctrl->bAutoSize) {
- int Height = ArrangeButtons();
- INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), 0);
- if (Height != 0 && Height != frameopt) {
- CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), Height);
- bResize = TRUE;
- }
- }
-
- if (g_ctrl->bOrderChanged)
- bResize = TRUE, g_ctrl->bOrderChanged = FALSE;
-
- if (bResize)
- CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)g_ctrl->hFrame, FU_FMPOS);
- }
- break;
-
- case TTB_SETCUSTOMDATASIZE:
- g_ctrl = (TTBCtrl*)mir_realloc(g_ctrl, lParam);
- if (lParam > sizeof(TTBCtrl))
- memset(g_ctrl+1, 0, lParam - sizeof(TTBCtrl));
-
- SetWindowLongPtr(hwnd, 0, (LONG_PTR)g_ctrl);
- break;
-
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return TRUE;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CALLBACK OnEventFire()
-{
- HWND parent = pcli->hwndContactList;
- if (parent == nullptr) // no clist, no buttons
- return;
-
- WNDCLASS wndclass = {0};
- wndclass.lpfnWndProc = TopToolBarProc;
- wndclass.cbWndExtra = sizeof(void *);
- wndclass.hInstance = hInst;
- wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
- wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
- wndclass.lpszClassName = pluginname;
- RegisterClass(&wndclass);
-
- g_ctrl->pButtonList = (SortedList *)&Buttons;
- g_ctrl->hWnd = CreateWindow(pluginname, L"Toolbar",
- WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
- 0, 0, 0, g_ctrl->nLastHeight, parent, nullptr, hInst, nullptr);
- SetWindowLongPtr(g_ctrl->hWnd, 0, (LONG_PTR)g_ctrl);
-
- LoadBackgroundOptions();
- LoadAllSeparators(); LoadAllLButs();
-
- // if we're working in skinned clist, receive the standard buttons & customizations
- if (g_CustomProc && g_ctrl->hWnd)
- g_CustomProc(TTB_WINDOW_HANDLE, g_ctrl->hWnd, g_CustomProcParam);
- else
- InitInternalButtons();
-
- // if there's no customized frames, create our own
- if (g_ctrl->hFrame == nullptr) {
- CLISTFrame Frame = { sizeof(Frame) };
- Frame.tname = L"Toolbar";
- Frame.hWnd = g_ctrl->hWnd;
- Frame.align = alTop;
- Frame.Flags = F_VISIBLE | F_NOBORDER | F_LOCKED | F_UNICODE;
- Frame.height = g_ctrl->nLastHeight;
- Frame.hIcon = Skin_LoadIcon(SKINICON_OTHER_FRAME);
- g_ctrl->hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0);
- }
-
- // receive buttons
- NotifyEventHooks(hTTBModuleLoaded, 0, 0);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-int LoadBackgroundOptions()
-{
- bkColour = db_get_dw(NULL, TTB_OPTDIR, "BkColour", TTBDEFAULT_BKCOLOUR);
- if (hBmpBackground) {
- DeleteObject(hBmpBackground);
- hBmpBackground = nullptr;
- }
-
- if (db_get_b(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) {
- ptrW tszBitmapName(db_get_wsa(NULL, TTB_OPTDIR, "BkBitmap"));
- if (tszBitmapName != NULL)
- hBmpBackground = Bitmap_Load(tszBitmapName);
- }
- backgroundBmpUse = db_get_w(NULL, TTB_OPTDIR, "BkBmpUse", TTBDEFAULT_BKBMPUSE);
-
- RECT rc;
- GetClientRect(g_ctrl->hWnd, &rc);
- InvalidateRect(g_ctrl->hWnd, &rc, TRUE);
- UpdateWindow(g_ctrl->hWnd);
- return 0;
-}
+
+#include "stdafx.h"
+
+COLORREF bkColour;
+HBITMAP hBmpBackground;
+int backgroundBmpUse;
+
+static wchar_t pluginname[] = L"TopToolBar";
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Toolbar window procedure
+
+static void PaintToolbar(HWND hwnd)
+{
+ InvalidateRect(hwnd, nullptr, FALSE);
+
+ PAINTSTRUCT paintst;
+ HDC hdc = BeginPaint(hwnd, &paintst);
+ RECT *rcPaint = &paintst.rcPaint;
+
+ RECT clRect;
+ GetClientRect(hwnd, &clRect);
+
+ int yScroll = 0;
+
+ HDC hdcMem = CreateCompatibleDC(hdc);
+ HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), nullptr);
+ HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcMem, hBmpOsb);
+ SetBkMode(hdcMem, TRANSPARENT);
+
+ HBRUSH hBrush = CreateSolidBrush(bkColour);
+ HBRUSH hoBrush = (HBRUSH)SelectObject(hdcMem, hBrush);
+ FillRect(hdcMem, rcPaint, hBrush);
+ SelectObject(hdcMem, hoBrush);
+ DeleteObject(hBrush);
+ if (hBmpBackground) {
+ BITMAP bmp;
+ GetObject(hBmpBackground, sizeof(bmp), &bmp);
+
+ HDC hdcBmp = CreateCompatibleDC(hdcMem);
+ SelectObject(hdcBmp, hBmpBackground);
+ int y = backgroundBmpUse & CLBF_SCROLL ? -yScroll : 0;
+ int maxx = backgroundBmpUse & CLBF_TILEH ? clRect.right : 1;
+ int maxy = backgroundBmpUse & CLBF_TILEV ? rcPaint->bottom : y+1;
+
+ int destw, desth;
+ 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 = g_ctrl->nButtonHeight+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 = g_ctrl->nButtonHeight+2;
+ break;
+ }
+
+ for (; y < maxy; y += desth) {
+ if (y < rcPaint->top - desth)
+ continue;
+
+ for (int 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);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static bool supressRepos = false;
+
+ switch(msg) {
+ case WM_CREATE:
+ g_ctrl->hWnd = hwnd;
+ PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0);
+ return FALSE;
+
+ case WM_DESTROY:
+ g_ctrl->hWnd = nullptr;
+ break;
+
+ case WM_MOVE:
+ return 0;
+
+ case WM_WINDOWPOSCHANGING:
+ case WM_SIZE:
+ if (g_ctrl->nLastHeight != HIWORD(lParam)) {
+ db_set_dw(0, TTB_OPTDIR, "LastHeight", g_ctrl->nLastHeight = HIWORD(lParam));
+ ArrangeButtons();
+ }
+ if (supressRepos) {
+ supressRepos = false;
+ break;
+ }
+ __fallthrough;
+
+ case TTB_REPOSBUTTONS:
+ if (g_ctrl->hWnd == hwnd) {
+ int iHeight = ArrangeButtons();
+ if ( g_ctrl->bAutoSize) {
+ RECT rcClient;
+ GetClientRect(g_ctrl->hWnd, &rcClient);
+ rcClient.bottom -= rcClient.top;
+ if (rcClient.bottom != iHeight && iHeight && rcClient.bottom) {
+ supressRepos = true;
+ PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0);
+ }
+ }
+ return 0;
+ }
+ break;
+
+ case WM_NCPAINT:
+ case WM_PAINT:
+ PaintToolbar(hwnd);
+ return 0;
+
+ case WM_LBUTTONDOWN:
+ if (db_get_b(NULL, "CLUI", "ClientAreaDrag", 0)) {
+ POINT pt;
+ GetCursorPos(&pt);
+ return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(pt.x, pt.y));
+ }
+ return 0;
+
+ case WM_COMMAND:
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
+ case BN_DOUBLECLICKED:
+ {
+ int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA);
+ if (id != 0) {
+ mir_cslock lck(csButtonsHook);
+ TopButtonInt* b = idtopos(id);
+ if (b == nullptr || b->isSep())
+ return 0;
+
+ if (b->dwFlags & TTBBF_ASPUSHBUTTON)
+ b->bPushed = !b->bPushed;
+
+ if (b->bPushed) { //Dn -> Up
+ if (!(b->dwFlags & TTBBF_ISLBUTTON)) // must be always true
+ if (b->pszService != nullptr)
+ CallService(b->pszService, b->wParamUp, b->lParamUp);
+ }
+ else { //Up -> Dn
+ if (b->pszService != nullptr)
+ CallService(b->pszService, b->wParamDown, b->lParamDown);
+ }
+
+ b->SetBitmap();
+ }
+ }
+ break;
+ }
+ break;
+
+ case TTB_UPDATEFRAMEVISIBILITY:
+ {
+ bool bResize = false;
+
+ if (g_ctrl->bAutoSize) {
+ int Height = ArrangeButtons();
+ INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), 0);
+ if (Height != 0 && Height != frameopt) {
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), Height);
+ bResize = TRUE;
+ }
+ }
+
+ if (g_ctrl->bOrderChanged)
+ bResize = TRUE, g_ctrl->bOrderChanged = FALSE;
+
+ if (bResize)
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)g_ctrl->hFrame, FU_FMPOS);
+ }
+ break;
+
+ case TTB_SETCUSTOMDATASIZE:
+ g_ctrl = (TTBCtrl*)mir_realloc(g_ctrl, lParam);
+ if (lParam > sizeof(TTBCtrl))
+ memset(g_ctrl+1, 0, lParam - sizeof(TTBCtrl));
+
+ SetWindowLongPtr(hwnd, 0, (LONG_PTR)g_ctrl);
+ break;
+
+ default:
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+ }
+ return TRUE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void CALLBACK OnEventFire()
+{
+ HWND parent = pcli->hwndContactList;
+ if (parent == nullptr) // no clist, no buttons
+ return;
+
+ WNDCLASS wndclass = {0};
+ wndclass.lpfnWndProc = TopToolBarProc;
+ wndclass.cbWndExtra = sizeof(void *);
+ wndclass.hInstance = g_plugin.getInst();
+ wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
+ wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
+ wndclass.lpszClassName = pluginname;
+ RegisterClass(&wndclass);
+
+ g_ctrl->pButtonList = (SortedList *)&Buttons;
+ g_ctrl->hWnd = CreateWindow(pluginname, L"Toolbar",
+ WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ 0, 0, 0, g_ctrl->nLastHeight, parent, nullptr, g_plugin.getInst(), nullptr);
+ SetWindowLongPtr(g_ctrl->hWnd, 0, (LONG_PTR)g_ctrl);
+
+ LoadBackgroundOptions();
+ LoadAllSeparators();
+ LoadAllLButs();
+
+ // if we're working in skinned clist, receive the standard buttons & customizations
+ if (g_CustomProc && g_ctrl->hWnd)
+ g_CustomProc(TTB_WINDOW_HANDLE, g_ctrl->hWnd, g_CustomProcParam);
+ else
+ InitInternalButtons();
+
+ // if there's no customized frames, create our own
+ if (g_ctrl->hFrame == nullptr) {
+ CLISTFrame Frame = { sizeof(Frame) };
+ Frame.tname = L"Toolbar";
+ Frame.hWnd = g_ctrl->hWnd;
+ Frame.align = alTop;
+ Frame.Flags = F_VISIBLE | F_NOBORDER | F_LOCKED | F_UNICODE;
+ Frame.height = g_ctrl->nLastHeight;
+ Frame.hIcon = Skin_LoadIcon(SKINICON_OTHER_FRAME);
+ g_ctrl->hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0);
+ }
+
+ // receive buttons
+ NotifyEventHooks(hTTBModuleLoaded, 0, 0);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int LoadBackgroundOptions()
+{
+ bkColour = db_get_dw(NULL, TTB_OPTDIR, "BkColour", TTBDEFAULT_BKCOLOUR);
+ if (hBmpBackground) {
+ DeleteObject(hBmpBackground);
+ hBmpBackground = nullptr;
+ }
+
+ if (db_get_b(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) {
+ ptrW tszBitmapName(db_get_wsa(NULL, TTB_OPTDIR, "BkBitmap"));
+ if (tszBitmapName != NULL)
+ hBmpBackground = Bitmap_Load(tszBitmapName);
+ }
+ backgroundBmpUse = db_get_w(NULL, TTB_OPTDIR, "BkBmpUse", TTBDEFAULT_BKBMPUSE);
+
+ RECT rc;
+ GetClientRect(g_ctrl->hWnd, &rc);
+ InvalidateRect(g_ctrl->hWnd, &rc, TRUE);
+ UpdateWindow(g_ctrl->hWnd);
+ return 0;
+}
diff --git a/plugins/TopToolBar/src/topbutton.cpp b/plugins/TopToolBar/src/topbutton.cpp
index b16bdd84f7..f9bf74a0fc 100644
--- a/plugins/TopToolBar/src/topbutton.cpp
+++ b/plugins/TopToolBar/src/topbutton.cpp
@@ -53,7 +53,7 @@ DWORD TopButtonInt::CheckFlags(DWORD Flags)
void TopButtonInt::CreateWnd()
{
if (!(dwFlags & TTBBF_ISSEPARATOR)) {
- hwnd = CreateWindow(TTB_BUTTON_CLASS, L"", BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP | SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, nullptr, hInst, this);
+ hwnd = CreateWindow(TTB_BUTTON_CLASS, L"", BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP | SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, nullptr, g_plugin.getInst(), this);
if (dwFlags & TTBBF_ASPUSHBUTTON)
SendMessage(hwnd, BUTTONSETASPUSHBTN, 1, 0);
@@ -65,7 +65,7 @@ void TopButtonInt::CreateWnd()
}
// maybe SEPWIDTH, not g_ctrl->nButtonWidth?
else
- hwnd = CreateWindow(L"STATIC", L"", WS_CHILD | SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, nullptr, hInst, nullptr);
+ hwnd = CreateWindow(L"STATIC", L"", WS_CHILD | SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, nullptr, g_plugin.getInst(), nullptr);
SetWindowLongPtr(hwnd, GWLP_USERDATA, id);
SetBitmap();
diff --git a/plugins/TopToolBar/src/ttbopt.cpp b/plugins/TopToolBar/src/ttbopt.cpp
index 27d1b36b2a..8c416d7200 100644
--- a/plugins/TopToolBar/src/ttbopt.cpp
+++ b/plugins/TopToolBar/src/ttbopt.cpp
@@ -276,7 +276,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (!(btn->dwFlags & TTBBF_OPTIONAL)) {
// create button
TTBButton ttb = {};
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.hIconDn = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
ttb.name = nullptr;
ttb.program = nullptr;
@@ -304,7 +304,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (ctrlid == IDC_ADDLBUTTON) {
// create button
TTBButton ttb = {};
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.hIconDn = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
ttb.name = LPGEN("Default");
ttb.program = L"Execute Path";
@@ -541,7 +541,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
int TTBOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.szGroup.a = LPGEN("Contact list");
odp.position = -1000000000;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_BUTORDER);